1 | /* $Id: pass1.h,v 1.215 2011/02/17 13:44:13 ragge Exp $ */
|
---|
2 | /*
|
---|
3 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * Redistributions of source code and documentation must retain the above
|
---|
10 | * copyright notice, this list of conditions and the following disclaimer.
|
---|
11 | * Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditionsand the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * All advertising materials mentioning features or use of this software
|
---|
15 | * must display the following acknowledgement:
|
---|
16 | * This product includes software developed or owned by Caldera
|
---|
17 | * International, Inc.
|
---|
18 | * Neither the name of Caldera International, Inc. nor the names of other
|
---|
19 | * contributors may be used to endorse or promote products derived from
|
---|
20 | * this software without specific prior written permission.
|
---|
21 | *
|
---|
22 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
|
---|
23 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
|
---|
24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
26 | * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
|
---|
27 | * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
30 | * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
|
---|
31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
---|
32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
---|
33 | * POSSIBILITY OF SUCH DAMAGE.
|
---|
34 | */
|
---|
35 |
|
---|
36 | #include "config.h"
|
---|
37 |
|
---|
38 | #include <sys/types.h>
|
---|
39 | #include <stdarg.h>
|
---|
40 | #include <string.h>
|
---|
41 | #ifdef HAVE_STDINT_H
|
---|
42 | #include <stdint.h>
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | #ifndef MKEXT
|
---|
46 | #include "external.h"
|
---|
47 | #else
|
---|
48 | typedef unsigned int bittype; /* XXX - for basicblock */
|
---|
49 | #endif
|
---|
50 | #include "manifest.h"
|
---|
51 |
|
---|
52 | #include "ccconfig.h"
|
---|
53 |
|
---|
54 | /*
|
---|
55 | * Storage classes
|
---|
56 | */
|
---|
57 | #define SNULL 0
|
---|
58 | #define AUTO 1
|
---|
59 | #define EXTERN 2
|
---|
60 | #define STATIC 3
|
---|
61 | #define REGISTER 4
|
---|
62 | #define EXTDEF 5
|
---|
63 | /* #define LABEL 6*/
|
---|
64 | /* #define ULABEL 7*/
|
---|
65 | #define MOS 8
|
---|
66 | #define PARAM 9
|
---|
67 | #define STNAME 10
|
---|
68 | #define MOU 11
|
---|
69 | #define UNAME 12
|
---|
70 | #define TYPEDEF 13
|
---|
71 | /* #define FORTRAN 14 */
|
---|
72 | #define ENAME 15
|
---|
73 | #define MOE 16
|
---|
74 | /* #define UFORTRAN 17 */
|
---|
75 | #define USTATIC 18
|
---|
76 |
|
---|
77 | /* field size is ORed in */
|
---|
78 | #define FIELD 0200
|
---|
79 | #define FLDSIZ 0177
|
---|
80 | extern char *scnames(int);
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * Symbol table flags
|
---|
84 | */
|
---|
85 | #define SNORMAL 0
|
---|
86 | #define STAGNAME 01
|
---|
87 | #define SLBLNAME 02
|
---|
88 | #define SMOSNAME 03
|
---|
89 | #define SSTRING 04
|
---|
90 | #define NSTYPES 05
|
---|
91 | #define SMASK 07
|
---|
92 |
|
---|
93 | /* #define SSET 00010 */
|
---|
94 | /* #define SREF 00020 */
|
---|
95 | #define SNOCREAT 00040 /* don't create a symbol in lookup() */
|
---|
96 | #define STEMP 00100 /* Allocate symtab from temp or perm mem */
|
---|
97 | #define SDYNARRAY 00200 /* symbol is dynamic array on stack */
|
---|
98 | #define SINLINE 00400 /* function is of type inline */
|
---|
99 | #define STNODE 01000 /* symbol shall be a temporary node */
|
---|
100 | #define SASG 04000 /* symbol is assigned to already */
|
---|
101 | #define SLOCAL1 010000
|
---|
102 | #define SLOCAL2 020000
|
---|
103 | #define SLOCAL3 040000
|
---|
104 |
|
---|
105 | /* alignment of initialized quantities */
|
---|
106 | #ifndef AL_INIT
|
---|
107 | #define AL_INIT ALINT
|
---|
108 | #endif
|
---|
109 |
|
---|
110 | struct rstack;
|
---|
111 | struct symtab;
|
---|
112 | union arglist;
|
---|
113 | #ifdef GCC_COMPAT
|
---|
114 | struct gcc_attr_pack;
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | /*
|
---|
118 | * Dimension/prototype information.
|
---|
119 | * ddim > 0 holds the dimension of an array.
|
---|
120 | * ddim < 0 is a dynamic array and refers to a tempnode.
|
---|
121 | * ...unless:
|
---|
122 | * ddim == NOOFFSET, an array without dimenston, "[]"
|
---|
123 | * ddim == -1, dynamic array while building before defid.
|
---|
124 | */
|
---|
125 | union dimfun {
|
---|
126 | int ddim; /* Dimension of an array */
|
---|
127 | union arglist *dfun; /* Prototype index */
|
---|
128 | };
|
---|
129 |
|
---|
130 | /*
|
---|
131 | * Argument list member info when storing prototypes.
|
---|
132 | */
|
---|
133 | union arglist {
|
---|
134 | TWORD type;
|
---|
135 | union dimfun *df;
|
---|
136 | struct attr *sap;
|
---|
137 | };
|
---|
138 | #define TNULL INCREF(FARG) /* pointer to FARG -- impossible type */
|
---|
139 | #define TELLIPSIS INCREF(INCREF(FARG))
|
---|
140 |
|
---|
141 | /*
|
---|
142 | * Symbol table definition.
|
---|
143 | */
|
---|
144 | struct symtab {
|
---|
145 | struct symtab *snext; /* link to other symbols in the same scope */
|
---|
146 | int soffset; /* offset or value */
|
---|
147 | char sclass; /* storage class */
|
---|
148 | char slevel; /* scope level */
|
---|
149 | short sflags; /* flags, see below */
|
---|
150 | char *sname; /* Symbol name */
|
---|
151 | char *soname; /* Written-out name */
|
---|
152 | TWORD stype; /* type word */
|
---|
153 | TWORD squal; /* qualifier word */
|
---|
154 | union dimfun *sdf; /* ptr to the dimension/prototype array */
|
---|
155 | struct attr *sap; /* the base type attribute list */
|
---|
156 | };
|
---|
157 |
|
---|
158 | struct attr2 {
|
---|
159 | struct attr *next;
|
---|
160 | int atype;
|
---|
161 | union aarg aa[2];
|
---|
162 | };
|
---|
163 |
|
---|
164 | #define ISSOU(ty) ((ty) == STRTY || (ty) == UNIONTY)
|
---|
165 | #define MKAP(type) ((struct attr *)&btattr[type])
|
---|
166 | extern const struct attr2 btattr[];
|
---|
167 |
|
---|
168 | /*
|
---|
169 | * External definitions
|
---|
170 | */
|
---|
171 | struct swents { /* switch table */
|
---|
172 | struct swents *next; /* Next struct in linked list */
|
---|
173 | CONSZ sval; /* case value */
|
---|
174 | int slab; /* associated label */
|
---|
175 | };
|
---|
176 | int mygenswitch(int, TWORD, struct swents **, int);
|
---|
177 |
|
---|
178 | extern int blevel;
|
---|
179 | extern int instruct, got_type;
|
---|
180 | extern int oldstyle;
|
---|
181 | extern int oflag;
|
---|
182 |
|
---|
183 | extern int lineno, nerrors;
|
---|
184 |
|
---|
185 | extern char *ftitle;
|
---|
186 | extern struct symtab *cftnsp;
|
---|
187 | extern int autooff, maxautooff, argoff, strucoff;
|
---|
188 | extern int brkflag;
|
---|
189 |
|
---|
190 | extern OFFSZ inoff;
|
---|
191 |
|
---|
192 | extern int reached;
|
---|
193 | extern int isinlining;
|
---|
194 | extern int xinline;
|
---|
195 |
|
---|
196 | extern int sdebug, idebug, pdebug;
|
---|
197 |
|
---|
198 | /* various labels */
|
---|
199 | extern int brklab;
|
---|
200 | extern int contlab;
|
---|
201 | extern int flostat;
|
---|
202 | extern int retlab;
|
---|
203 |
|
---|
204 | /* pragma globals */
|
---|
205 | extern int pragma_allpacked, pragma_packed, pragma_aligned;
|
---|
206 | extern char *pragma_renamed;
|
---|
207 |
|
---|
208 | /*
|
---|
209 | * Flags used in the (elementary) flow analysis ...
|
---|
210 | */
|
---|
211 | #define FBRK 02
|
---|
212 | #define FCONT 04
|
---|
213 | #define FDEF 010
|
---|
214 | #define FLOOP 020
|
---|
215 |
|
---|
216 | /* mark an offset which is undefined */
|
---|
217 |
|
---|
218 | #define NOOFFSET (-10201)
|
---|
219 |
|
---|
220 | /* declarations of various functions */
|
---|
221 | extern NODE
|
---|
222 | *buildtree(int, NODE *, NODE *r),
|
---|
223 | *mkty(unsigned, union dimfun *, struct attr *),
|
---|
224 | *rstruct(char *, int),
|
---|
225 | *dclstruct(struct rstack *),
|
---|
226 | *strend(int gtype, char *),
|
---|
227 | *tymerge(NODE *, NODE *),
|
---|
228 | *stref(NODE *),
|
---|
229 | *offcon(OFFSZ, TWORD, union dimfun *, struct attr *),
|
---|
230 | *bcon(int),
|
---|
231 | *xbcon(CONSZ, struct symtab *, TWORD),
|
---|
232 | *bpsize(NODE *),
|
---|
233 | *convert(NODE *, int),
|
---|
234 | *pconvert(NODE *),
|
---|
235 | *oconvert(NODE *),
|
---|
236 | *ptmatch(NODE *),
|
---|
237 | *tymatch(NODE *),
|
---|
238 | *makety(NODE *, TWORD, TWORD, union dimfun *, struct attr *),
|
---|
239 | *block(int, NODE *, NODE *, TWORD, union dimfun *, struct attr *),
|
---|
240 | *doszof(NODE *),
|
---|
241 | *talloc(void),
|
---|
242 | *optim(NODE *),
|
---|
243 | *clocal(NODE *),
|
---|
244 | *ccopy(NODE *),
|
---|
245 | *tempnode(int, TWORD, union dimfun *, struct attr *),
|
---|
246 | *eve(NODE *),
|
---|
247 | *doacall(struct symtab *, NODE *, NODE *);
|
---|
248 | NODE *intprom(NODE *);
|
---|
249 | OFFSZ tsize(TWORD, union dimfun *, struct attr *),
|
---|
250 | psize(NODE *);
|
---|
251 | NODE * typenode(NODE *new);
|
---|
252 | void spalloc(NODE *, NODE *, OFFSZ);
|
---|
253 | char *exname(char *);
|
---|
254 | NODE *floatcon(char *);
|
---|
255 | NODE *fhexcon(char *);
|
---|
256 | NODE *bdty(int op, ...);
|
---|
257 | extern struct rstack *rpole;
|
---|
258 |
|
---|
259 | int oalloc(struct symtab *, int *);
|
---|
260 | void deflabel(char *, NODE *);
|
---|
261 | void gotolabel(char *);
|
---|
262 | unsigned int esccon(char **);
|
---|
263 | void inline_start(struct symtab *);
|
---|
264 | void inline_end(void);
|
---|
265 | void inline_addarg(struct interpass *);
|
---|
266 | void inline_ref(struct symtab *);
|
---|
267 | void inline_prtout(void);
|
---|
268 | void inline_args(struct symtab **, int);
|
---|
269 | NODE *inlinetree(struct symtab *, NODE *, NODE *);
|
---|
270 | void ftnarg(NODE *);
|
---|
271 | struct rstack *bstruct(char *, int, NODE *);
|
---|
272 | void moedef(char *);
|
---|
273 | void beginit(struct symtab *);
|
---|
274 | void simpleinit(struct symtab *, NODE *);
|
---|
275 | struct symtab *lookup(char *, int);
|
---|
276 | struct symtab *getsymtab(char *, int);
|
---|
277 | char *addstring(char *);
|
---|
278 | char *addname(char *);
|
---|
279 | void symclear(int);
|
---|
280 | struct symtab *hide(struct symtab *);
|
---|
281 | void soumemb(NODE *, char *, int);
|
---|
282 | int talign(unsigned int, struct attr *);
|
---|
283 | void bfcode(struct symtab **, int);
|
---|
284 | int chkftn(union arglist *, union arglist *);
|
---|
285 | void branch(int);
|
---|
286 | void cbranch(NODE *, NODE *);
|
---|
287 | void extdec(struct symtab *);
|
---|
288 | void defzero(struct symtab *);
|
---|
289 | int falloc(struct symtab *, int, NODE *);
|
---|
290 | TWORD ctype(TWORD);
|
---|
291 | void ninval(CONSZ, int, NODE *);
|
---|
292 | void infld(CONSZ, int, CONSZ);
|
---|
293 | void zbits(CONSZ, int);
|
---|
294 | void instring(struct symtab *);
|
---|
295 | void inwstring(struct symtab *);
|
---|
296 | void plabel(int);
|
---|
297 | void bjobcode(void);
|
---|
298 | void ejobcode(int);
|
---|
299 | void calldec(NODE *, NODE *);
|
---|
300 | int cisreg(TWORD);
|
---|
301 | char *tmpsprintf(char *, ...);
|
---|
302 | char *tmpvsprintf(char *, va_list);
|
---|
303 | void asginit(NODE *);
|
---|
304 | void desinit(NODE *);
|
---|
305 | void endinit(void);
|
---|
306 | void endictx(void);
|
---|
307 | void sspinit(void);
|
---|
308 | void sspstart(void);
|
---|
309 | void sspend(void);
|
---|
310 | void ilbrace(void);
|
---|
311 | void irbrace(void);
|
---|
312 | CONSZ scalinit(NODE *);
|
---|
313 | void p1print(char *, ...);
|
---|
314 | char *copst(int);
|
---|
315 | int cdope(int);
|
---|
316 | void myp2tree(NODE *);
|
---|
317 | void lcommprint(void);
|
---|
318 | void lcommdel(struct symtab *);
|
---|
319 | NODE *funcode(NODE *);
|
---|
320 | struct symtab *enumhd(char *);
|
---|
321 | NODE *enumdcl(struct symtab *);
|
---|
322 | NODE *enumref(char *);
|
---|
323 | CONSZ icons(NODE *);
|
---|
324 | CONSZ valcast(CONSZ v, TWORD t);
|
---|
325 | int mypragma(char *);
|
---|
326 | char *pragtok(char *);
|
---|
327 | int eat(int);
|
---|
328 | void fixdef(struct symtab *);
|
---|
329 | int cqual(TWORD, TWORD);
|
---|
330 | void defloc(struct symtab *);
|
---|
331 | int fldchk(int);
|
---|
332 | int nncon(NODE *);
|
---|
333 | void cunput(char);
|
---|
334 | NODE *nametree(struct symtab *sp);
|
---|
335 | void *inlalloc(int size);
|
---|
336 | void *blkalloc(int size);
|
---|
337 | void pass1_lastchance(struct interpass *);
|
---|
338 | void fldty(struct symtab *p);
|
---|
339 | int getlab(void);
|
---|
340 | struct suedef *sueget(struct suedef *p);
|
---|
341 | void complinit(void);
|
---|
342 | NODE *structref(NODE *p, int f, char *name);
|
---|
343 | NODE *cxop(int op, NODE *l, NODE *r);
|
---|
344 | NODE *imop(int op, NODE *l, NODE *r);
|
---|
345 | NODE *cxelem(int op, NODE *p);
|
---|
346 | NODE *cxconj(NODE *p);
|
---|
347 | NODE *cxret(NODE *p, NODE *q);
|
---|
348 | NODE *cast(NODE *p, TWORD t, TWORD q);
|
---|
349 | NODE *ccast(NODE *p, TWORD t, TWORD u, union dimfun *df, struct attr *sue);
|
---|
350 | int andable(NODE *);
|
---|
351 | int conval(NODE *, int, NODE *);
|
---|
352 | int ispow2(CONSZ);
|
---|
353 | void defid(NODE *q, int class);
|
---|
354 | void efcode(void);
|
---|
355 | void ecomp(NODE *p);
|
---|
356 | void cendarg(void);
|
---|
357 | int fldal(unsigned int);
|
---|
358 | int upoff(int size, int alignment, int *poff);
|
---|
359 | void nidcl(NODE *p, int class);
|
---|
360 | void eprint(NODE *, int, int *, int *);
|
---|
361 | int uclass(int class);
|
---|
362 | int notlval(NODE *);
|
---|
363 | void ecode(NODE *p);
|
---|
364 | void bccode(void);
|
---|
365 | void ftnend(void);
|
---|
366 | void dclargs(void);
|
---|
367 | int suemeq(struct attr *s1, struct attr *s2);
|
---|
368 | struct symtab *strmemb(struct attr *ap);
|
---|
369 | int yylex(void);
|
---|
370 | void yyerror(char *);
|
---|
371 | int pragmas_gcc(char *t);
|
---|
372 |
|
---|
373 | NODE *builtin_check(NODE *f, NODE *a);
|
---|
374 |
|
---|
375 | #ifdef SOFTFLOAT
|
---|
376 | typedef struct softfloat SF;
|
---|
377 | SF soft_neg(SF);
|
---|
378 | SF soft_cast(CONSZ v, TWORD);
|
---|
379 | SF soft_plus(SF, SF);
|
---|
380 | SF soft_minus(SF, SF);
|
---|
381 | SF soft_mul(SF, SF);
|
---|
382 | SF soft_div(SF, SF);
|
---|
383 | int soft_cmp_eq(SF, SF);
|
---|
384 | int soft_cmp_ne(SF, SF);
|
---|
385 | int soft_cmp_ge(SF, SF);
|
---|
386 | int soft_cmp_gt(SF, SF);
|
---|
387 | int soft_cmp_le(SF, SF);
|
---|
388 | int soft_cmp_lt(SF, SF);
|
---|
389 | int soft_isz(SF);
|
---|
390 | CONSZ soft_val(SF);
|
---|
391 | #define FLOAT_NEG(sf) soft_neg(sf)
|
---|
392 | #define FLOAT_CAST(v,t) soft_cast(v, t)
|
---|
393 | #define FLOAT_PLUS(x1,x2) soft_plus(x1, x2)
|
---|
394 | #define FLOAT_MINUS(x1,x2) soft_minus(x1, x2)
|
---|
395 | #define FLOAT_MUL(x1,x2) soft_mul(x1, x2)
|
---|
396 | #define FLOAT_DIV(x1,x2) soft_div(x1, x2)
|
---|
397 | #define FLOAT_ISZERO(sf) soft_isz(sf)
|
---|
398 | #define FLOAT_VAL(sf) soft_val(sf)
|
---|
399 | #define FLOAT_EQ(x1,x2) soft_cmp_eq(x1, x2)
|
---|
400 | #define FLOAT_NE(x1,x2) soft_cmp_ne(x1, x2)
|
---|
401 | #define FLOAT_GE(x1,x2) soft_cmp_ge(x1, x2)
|
---|
402 | #define FLOAT_GT(x1,x2) soft_cmp_gt(x1, x2)
|
---|
403 | #define FLOAT_LE(x1,x2) soft_cmp_le(x1, x2)
|
---|
404 | #define FLOAT_LT(x1,x2) soft_cmp_lt(x1, x2)
|
---|
405 | #else
|
---|
406 | #define FLOAT_NEG(p) -(p)
|
---|
407 | #define FLOAT_CAST(p,v) (ISUNSIGNED(v) ? \
|
---|
408 | (long double)(U_CONSZ)(p) : (long double)(CONSZ)(p))
|
---|
409 | #define FLOAT_PLUS(x1,x2) (x1) + (x2)
|
---|
410 | #define FLOAT_MINUS(x1,x2) (x1) - (x2)
|
---|
411 | #define FLOAT_MUL(x1,x2) (x1) * (x2)
|
---|
412 | #define FLOAT_DIV(x1,x2) (x1) / (x2)
|
---|
413 | #define FLOAT_ISZERO(p) (p) == 0.0
|
---|
414 | #define FLOAT_VAL(p) (CONSZ)(p)
|
---|
415 | #define FLOAT_EQ(x1,x2) (x1) == (x2)
|
---|
416 | #define FLOAT_NE(x1,x2) (x1) != (x2)
|
---|
417 | #define FLOAT_GE(x1,x2) (x1) >= (x2)
|
---|
418 | #define FLOAT_GT(x1,x2) (x1) > (x2)
|
---|
419 | #define FLOAT_LE(x1,x2) (x1) <= (x2)
|
---|
420 | #define FLOAT_LT(x1,x2) (x1) < (x2)
|
---|
421 | #endif
|
---|
422 |
|
---|
423 | enum { ATTR_NONE,
|
---|
424 |
|
---|
425 | /* PCC used attributes */
|
---|
426 | ATTR_COMPLEX, /* Internal definition of complex */
|
---|
427 | ATTR_BASETYP, /* Internal; see below */
|
---|
428 | ATTR_QUALTYP, /* Internal; const/volatile, see below */
|
---|
429 | ATTR_STRUCT, /* Internal; element list */
|
---|
430 | #define ATTR_MAX ATTR_STRUCT
|
---|
431 |
|
---|
432 | #ifdef GCC_COMPAT
|
---|
433 | /* type attributes */
|
---|
434 | GCC_ATYP_ALIGNED,
|
---|
435 | GCC_ATYP_PACKED,
|
---|
436 | GCC_ATYP_SECTION,
|
---|
437 | GCC_ATYP_TRANSP_UNION,
|
---|
438 | GCC_ATYP_UNUSED,
|
---|
439 | GCC_ATYP_DEPRECATED,
|
---|
440 | GCC_ATYP_MAYALIAS,
|
---|
441 |
|
---|
442 | /* variable attributes */
|
---|
443 | GCC_ATYP_MODE,
|
---|
444 |
|
---|
445 | /* function attributes */
|
---|
446 | GCC_ATYP_NORETURN,
|
---|
447 | GCC_ATYP_FORMAT,
|
---|
448 | GCC_ATYP_NONNULL,
|
---|
449 | GCC_ATYP_SENTINEL,
|
---|
450 | GCC_ATYP_WEAK,
|
---|
451 | GCC_ATYP_FORMATARG,
|
---|
452 | GCC_ATYP_GNU_INLINE,
|
---|
453 | GCC_ATYP_MALLOC,
|
---|
454 | GCC_ATYP_NOTHROW,
|
---|
455 | GCC_ATYP_CONST,
|
---|
456 | GCC_ATYP_PURE,
|
---|
457 | GCC_ATYP_CONSTRUCTOR,
|
---|
458 | GCC_ATYP_DESTRUCTOR,
|
---|
459 | GCC_ATYP_VISIBILITY,
|
---|
460 | GCC_ATYP_STDCALL,
|
---|
461 | GCC_ATYP_CDECL,
|
---|
462 | GCC_ATYP_WARN_UNUSED_RESULT,
|
---|
463 | GCC_ATYP_USED,
|
---|
464 | GCC_ATYP_NO_INSTR_FUN,
|
---|
465 | GCC_ATYP_NOINLINE,
|
---|
466 | GCC_ATYP_ALIAS,
|
---|
467 | GCC_ATYP_WEAKREF,
|
---|
468 | GCC_ATYP_ALLOCSZ,
|
---|
469 | GCC_ATYP_ALW_INL,
|
---|
470 | GCC_ATYP_TLSMODEL,
|
---|
471 | GCC_ATYP_ALIASWEAK,
|
---|
472 |
|
---|
473 | /* other stuff */
|
---|
474 | GCC_ATYP_BOUNDED, /* OpenBSD extra boundary checks */
|
---|
475 |
|
---|
476 | GCC_ATYP_MAX
|
---|
477 | #endif
|
---|
478 | };
|
---|
479 |
|
---|
480 |
|
---|
481 | /*
|
---|
482 | * ATTR_BASETYP has the following layout:
|
---|
483 | * aa[0].iarg has size
|
---|
484 | * aa[1].iarg has alignment
|
---|
485 | * ATTR_QUALTYP has the following layout:
|
---|
486 | * aa[0].iarg has CON/VOL + FUN/ARY/PTR
|
---|
487 | * Not defined yet...
|
---|
488 | * aa[3].iarg is dimension for arrays (XXX future)
|
---|
489 | * aa[3].varg is function defs for functions.
|
---|
490 | */
|
---|
491 | #define atypsz aa[0].iarg
|
---|
492 | #define aalign aa[1].iarg
|
---|
493 |
|
---|
494 | /*
|
---|
495 | * ATTR_STRUCT member list.
|
---|
496 | */
|
---|
497 | #define amlist aa[0].varg
|
---|
498 | #define strattr(x) (attr_find(x, ATTR_STRUCT))
|
---|
499 |
|
---|
500 | #define iarg(x) aa[x].iarg
|
---|
501 | #define sarg(x) aa[x].sarg
|
---|
502 | #define varg(x) aa[x].varg
|
---|
503 |
|
---|
504 | void gcc_init(void);
|
---|
505 | int gcc_keyword(char *, NODE **);
|
---|
506 | struct attr *gcc_attr_parse(NODE *);
|
---|
507 | void gcc_tcattrfix(NODE *);
|
---|
508 | struct gcc_attrib *gcc_get_attr(struct suedef *, int);
|
---|
509 | void dump_attr(struct attr *gap);
|
---|
510 |
|
---|
511 | struct attr *attr_add(struct attr *orig, struct attr *new);
|
---|
512 | struct attr *attr_new(int, int);
|
---|
513 | struct attr *attr_find(struct attr *, int);
|
---|
514 | struct attr *attr_copy(struct attr *src, struct attr *dst, int nelem);
|
---|
515 | struct attr *attr_dup(struct attr *ap, int n);
|
---|
516 |
|
---|
517 | #ifdef STABS
|
---|
518 | void stabs_init(void);
|
---|
519 | void stabs_file(char *);
|
---|
520 | void stabs_efile(char *);
|
---|
521 | void stabs_line(int);
|
---|
522 | void stabs_rbrac(int);
|
---|
523 | void stabs_lbrac(int);
|
---|
524 | void stabs_func(struct symtab *);
|
---|
525 | void stabs_newsym(struct symtab *);
|
---|
526 | void stabs_chgsym(struct symtab *);
|
---|
527 | void stabs_struct(struct symtab *, struct attr *);
|
---|
528 | #endif
|
---|
529 |
|
---|
530 | #ifndef CHARCAST
|
---|
531 | /* to make character constants into character connstants */
|
---|
532 | /* this is a macro to defend against cross-compilers, etc. */
|
---|
533 | #define CHARCAST(x) (char)(x)
|
---|
534 | #endif
|
---|
535 |
|
---|
536 | /* sometimes int is smaller than pointers */
|
---|
537 | #if SZPOINT(CHAR) <= SZINT
|
---|
538 | #define INTPTR INT
|
---|
539 | #elif SZPOINT(CHAR) <= SZLONG
|
---|
540 | #define INTPTR LONG
|
---|
541 | #elif SZPOINT(CHAR) <= SZLONGLONG
|
---|
542 | #define INTPTR LONGLONG
|
---|
543 | #else
|
---|
544 | #error int size unknown
|
---|
545 | #endif
|
---|
546 |
|
---|
547 | /*
|
---|
548 | * C compiler first pass extra defines.
|
---|
549 | */
|
---|
550 | #define QUALIFIER (MAXOP+1)
|
---|
551 | #define CLASS (MAXOP+2)
|
---|
552 | #define RB (MAXOP+3)
|
---|
553 | #define DOT (MAXOP+4)
|
---|
554 | #define ELLIPSIS (MAXOP+5)
|
---|
555 | #define TYPE (MAXOP+6)
|
---|
556 | #define LB (MAXOP+7)
|
---|
557 | #define COMOP (MAXOP+8)
|
---|
558 | #define QUEST (MAXOP+9)
|
---|
559 | #define COLON (MAXOP+10)
|
---|
560 | #define ANDAND (MAXOP+11)
|
---|
561 | #define OROR (MAXOP+12)
|
---|
562 | #define NOT (MAXOP+13)
|
---|
563 | #define CAST (MAXOP+14)
|
---|
564 | #define STRING (MAXOP+15)
|
---|
565 |
|
---|
566 | /* The following must be in the same order as their NOASG counterparts */
|
---|
567 | #define PLUSEQ (MAXOP+16)
|
---|
568 | #define MINUSEQ (MAXOP+17)
|
---|
569 | #define DIVEQ (MAXOP+18)
|
---|
570 | #define MODEQ (MAXOP+19)
|
---|
571 | #define MULEQ (MAXOP+20)
|
---|
572 | #define ANDEQ (MAXOP+21)
|
---|
573 | #define OREQ (MAXOP+22)
|
---|
574 | #define EREQ (MAXOP+23)
|
---|
575 | #define LSEQ (MAXOP+24)
|
---|
576 | #define RSEQ (MAXOP+25)
|
---|
577 |
|
---|
578 | #define UNASG (-(PLUSEQ-PLUS))+
|
---|
579 |
|
---|
580 | #define INCR (MAXOP+26)
|
---|
581 | #define DECR (MAXOP+27)
|
---|
582 | #define SZOF (MAXOP+28)
|
---|
583 | #define CLOP (MAXOP+29)
|
---|
584 | #define ATTRIB (MAXOP+30)
|
---|
585 | #define XREAL (MAXOP+31)
|
---|
586 | #define XIMAG (MAXOP+32)
|
---|
587 | #define TYMERGE (MAXOP+33)
|
---|
588 |
|
---|
589 |
|
---|
590 | /*
|
---|
591 | * The following types are only used in pass1.
|
---|
592 | */
|
---|
593 | #define SIGNED (MAXTYPES+1)
|
---|
594 | #define BOOL (MAXTYPES+2)
|
---|
595 | #define FIMAG (MAXTYPES+3)
|
---|
596 | #define IMAG (MAXTYPES+4)
|
---|
597 | #define LIMAG (MAXTYPES+5)
|
---|
598 | #define FCOMPLEX (MAXTYPES+6)
|
---|
599 | #define COMPLEX (MAXTYPES+7)
|
---|
600 | #define LCOMPLEX (MAXTYPES+8)
|
---|
601 | #define ENUMTY (MAXTYPES+9)
|
---|
602 |
|
---|
603 | #define ISFTY(x) ((x) >= FLOAT && (x) <= LDOUBLE)
|
---|
604 | #define ISCTY(x) ((x) >= FCOMPLEX && (x) <= LCOMPLEX)
|
---|
605 | #define ISITY(x) ((x) >= FIMAG && (x) <= LIMAG)
|
---|
606 | #define ANYCX(p) (p->n_type == STRTY && attr_find(p->n_ap, ATTR_COMPLEX))
|
---|
607 |
|
---|
608 | #define coptype(o) (cdope(o)&TYFLG)
|
---|
609 | #define clogop(o) (cdope(o)&LOGFLG)
|
---|
610 | #define casgop(o) (cdope(o)&ASGFLG)
|
---|
611 |
|
---|