Debian Codegraph @

cc/ccom/pass1.h

raw symbols SCIP
1 /* $Id: pass1.h,v 1.320 2021/10/13 17:07:03 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 #include <stdlib.h>
45
46 #ifndef MKEXT
47 #include "external.h"
48 #else
49 typedef unsigned int bittype; /* XXX - for basicblock */
50 #endif
51 #include "manifest.h"
52 #include "softfloat.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 THLOCAL 6
64 #define KEYWORD 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 STLS 00010 /* Thread Local Support variable */
94 #define SINSYS 00020 /* Declared in system header */
95 #define SSTMT SINSYS /* Allocate symtab on statement stack */
96 #define SNOCREAT 00040 /* don't create a symbol in lookup() */
97 #define STEMP 00100 /* Allocate symtab from temp or perm mem */
98 #define SDYNARRAY 00200 /* symbol is dynamic array on stack */
99 #define SINLINE 00400 /* function is of type inline */
100 #define SBLK SINLINE /* Allocate symtab from blk mem */
101 #define STNODE 01000 /* symbol shall be a temporary node */
102 #define SBUILTIN 02000 /* this is a builtin function */
103 #define SASG 04000 /* symbol is assigned to already */
104 #define SINREG 010000 /* variable is put in reg */
105
106 /* alignment of initialized quantities */
107 #ifndef AL_INIT
108 #define AL_INIT ALINT
109 #endif
110
111 struct rstack;
112 struct symtab;
113 union arglist;
114 #ifdef GCC_COMPAT
115 struct gcc_attr_pack;
116 #endif
117
118 /*
119 * Dimension/prototype information.
120 * ddim > 0 holds the dimension of an array.
121 * ddim < 0 is a dynamic array and refers to a tempnode.
122 * ...unless:
123 * ddim == NOOFFSET, an array without dimenston, "[]"
124 * ddim == -1, dynamic array while building before defid.
125 */
126 union dimfun {
127 int ddim; /* Dimension of an array */
128 union arglist *dfun; /* Prototype index */
129 };
130
131 /*
132 * Argument list member info when storing prototypes.
133 */
134 union arglist {
135 TWORD type;
136 union dimfun *df;
137 struct attr *sap;
138 };
139 #define TNULL INCREF(FARG) /* pointer to FARG -- impossible type */
140 #define TELLIPSIS INCREF(INCREF(FARG))
141
142 /*
143 * Symbol table definition.
144 */
145 struct symtab {
146 struct symtab *snext; /* link to other symbols in the same scope */
147 int soffset; /* offset or value */
148 char sclass; /* storage class */
149 char slevel; /* scope level */
150 short sflags; /* flags, see below */
151 char *sname; /* Symbol 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 #define ISSOU(ty) ((ty) == STRTY || (ty) == UNIONTY)
159
160 /*
161 * External definitions
162 */
163 struct swents { /* switch table */
164 struct swents *next; /* Next struct in linked list */
165 CONSZ sval; /* case value */
166 int slab; /* associated label */
167 };
168 int mygenswitch(int, TWORD, struct swents **, int);
169
170 extern int blevel;
171 extern int oldstyle;
172
173 extern int lineno, nerrors, issyshdr;
174
175 extern char *ftitle;
176 extern struct symtab *cftnsp;
177 extern int autooff, maxautooff, argoff;
178
179 extern OFFSZ inoff;
180
181 extern int reached;
182 extern int isinlining;
183 extern int xinline, xgnu89, xgnu99;
184 extern int bdebug, ddebug, edebug, idebug, ndebug;
185 extern int odebug, pdebug, sdebug, tdebug, xdebug;
186
187 /* various labels */
188 extern int brklab;
189 extern int contlab;
190 extern int flostat, fp_contract;
191 extern int retlab;
192 extern int doing_init, statinit;
193 extern short sztable[];
194 extern char *astypnames[];
195
196 /* pragma globals */
197 extern int pragma_allpacked, pragma_packed, pragma_aligned;
198
199 /*
200 * Flags used in the (elementary) flow analysis ...
201 */
202 #define FBRK 02
203 #define FCONT 04
204 #define FDEF 010
205 #define FLOOP 020
206 #define FP_CONTR_CBR 040 /* use same flag field */
207 /*
208 * Location counters
209 */
210 #define NOSEG -1
211 #define PROG 0 /* (ro) program segment */
212 #define DATA 1 /* (rw) data segment */
213 #define RDATA 2 /* (ro) data segment */
214 #define LDATA 3 /* (rw) local data */
215 #define UDATA 4 /* (rw) uninitialized data */
216 #define STRNG 5 /* (ro) string segment */
217 #define PICDATA 6 /* (rw) relocatable data segment */
218 #define PICRDATA 7 /* (ro) relocatable data segment */
219 #define PICLDATA 8 /* (rw) local relocatable data */
220 #define TLSDATA 9 /* (rw) TLS data segment */
221 #define TLSUDATA 10 /* (rw) TLS uninitialized segment */
222 #define CTORS 11 /* constructor */
223 #define DTORS 12 /* destructor */
224 #define NMSEG 13 /* other (named) segment */
225
226 extern int lastloc;
227 void locctr(int type, struct symtab *sp);
228 void setseg(int type, char *name);
229 void defalign(int al);
230 void symdirec(struct symtab *sp);
231
232 /*
233 * Tree struct for pass1.
234 */
235 struct flt;
236
237 typedef struct p1node {
238 int n_op;
239 TWORD n_type;
240 TWORD n_qual;
241 union {
242 char * _name;
243 union dimfun *_df;
244 } n_5;
245 struct attr *n_ap;
246 union {
247 struct {
248 union {
249 struct p1node *_left;
250 CONSZ _val;
251 } n_l;
252 union {
253 struct p1node *_right;
254 int _rval;
255 struct symtab *_sp;
256 } n_r;
257 } n_u;
258 struct softfloat *_scon;
259 } n_f;
260 } P1ND;
261
262 #define glval(p) ((p)->n_f.n_u.n_l._val)
263 #define slval(p,v) ((p)->n_f.n_u.n_l._val = (v))
264 #define n_ccon n_f._ccon
265 #define n_scon n_f._scon
266
267
268 /* mark an offset which is undefined */
269
270 #define NOOFFSET (-10201)
271
272 /* declarations of various functions */
273 extern P1ND
274 *buildtree(int, P1ND *, P1ND *r),
275 *mkty(unsigned, union dimfun *, struct attr *),
276 *rstruct(char *, int),
277 *dclstruct(struct rstack *),
278 *strend(char *, TWORD),
279 *tymerge(P1ND *, P1ND *),
280 *stref(P1ND *),
281 #ifdef WORD_ADDRESSED
282 *offcon(OFFSZ, TWORD, union dimfun *, struct attr *),
283 #endif
284 *bcon(int),
285 *xbcon(CONSZ, struct symtab *, TWORD),
286 *bpsize(P1ND *),
287 *convert(P1ND *, int),
288 *pconvert(P1ND *),
289 *oconvert(P1ND *),
290 *ptmatch(P1ND *),
291 *makety(P1ND *, TWORD, TWORD, union dimfun *, struct attr *),
292 *block(int, P1ND *, P1ND *, TWORD, union dimfun *, struct attr *),
293 *doszof(P1ND *),
294 *p1alloc(void),
295 *optim(P1ND *),
296 *clocal(P1ND *),
297 *tempnode(int, TWORD, union dimfun *, struct attr *),
298 *eve(P1ND *),
299 *doacall(struct symtab *, P1ND *, P1ND *);
300 P1ND *intprom(P1ND *);
301 OFFSZ tsize(TWORD, union dimfun *, struct attr *),
302 psize(P1ND *);
303 P1ND * typenode(P1ND *new);
304 void spalloc(P1ND *, P1ND *, OFFSZ);
305 char *exname(char *);
306 void floatcon(char *);
307 P1ND *bdty(int op, ...);
308 extern struct rstack *rpole;
309
310 int oalloc(struct symtab *, int *);
311 void deflabel(char *, P1ND *);
312 void gotolabel(char *);
313 unsigned int esccon(char **);
314 void inline_start(struct symtab *, int class);
315 void inline_end(void);
316 void inline_addarg(struct interpass *);
317 void inline_ref(struct symtab *);
318 void inline_prtout(void);
319 void inline_args(struct symtab **, int);
320 P1ND *inlinetree(struct symtab *, P1ND *, P1ND *);
321 void argsave(P1ND *p);
322 struct rstack *bstruct(char *, int, P1ND *);
323 void moedef(char *);
324 void beginit(struct symtab *);
325 void simpleinit(struct symtab *, P1ND *);
326 struct symtab *lookup(char *, int);
327 struct symtab *getsymtab(char *, int);
328 char *addstring(char *);
329 char *addname(char *);
330 void symclear(int);
331 struct symtab *hide(struct symtab *);
332 void soumemb(P1ND *, char *, int);
333 int talign(unsigned int, struct attr *);
334 void bfcode(struct symtab **, int);
335 int chkftn(union arglist *, union arglist *);
336 void branch(int);
337 void cbranch(P1ND *, P1ND *);
338 void extdec(struct symtab *);
339 void defzero(struct symtab *);
340 int falloc(struct symtab *, int, P1ND *);
341 TWORD ctype(TWORD);
342 void inval(CONSZ, int, P1ND *);
343 int ninval(CONSZ, int, P1ND *);
344 void infld(CONSZ, int, CONSZ);
345 void zbits(CONSZ, int);
346 void instring(struct symtab *);
347 void inwstring(struct symtab *);
348 void plabel(int);
349 void bjobcode(void);
350 void ejobcode(int);
351 void calldec(P1ND *, P1ND *);
352 int cisreg(TWORD);
353 void asginit(P1ND *);
354 void desinit(P1ND *);
355 void endinit(int);
356 void endictx(void);
357 void sspinit(void);
358 void sspstart(void);
359 void sspend(void);
360 void ilbrace(void);
361 void irbrace(void);
362 CONSZ scalinit(P1ND *);
363 void p1print(char *, ...);
364 char *copst(int);
365 int cdope(int);
366 void myp2tree(P1ND *);
367 void lcommprint(void), strprint(void);
368 void lcommdel(struct symtab *);
369 P1ND *funcode(P1ND *);
370 struct symtab *enumhd(char *);
371 P1ND *enumdcl(struct symtab *);
372 P1ND *enumref(char *);
373 CONSZ icons(P1ND *);
374 CONSZ valcast(CONSZ v, TWORD t);
375 int mypragma(char *);
376 char *pragtok(char *);
377 int eat(int);
378 void fixdef(struct symtab *);
379 int cqual(TWORD, TWORD);
380 void defloc(struct symtab *);
381 int fldchk(int);
382 int nncon(P1ND *);
383 void cunput(char);
384 P1ND *nametree(struct symtab *sp);
385 void pass1_lastchance(struct interpass *);
386 void fldty(struct symtab *p);
387 struct suedef *sueget(struct suedef *p);
388 void complinit(void);
389 void kwinit(void);
390 P1ND *structref(P1ND *p, int f, char *name);
391 P1ND *cxop(int op, P1ND *l, P1ND *r);
392 P1ND *imop(int op, P1ND *l, P1ND *r);
393 P1ND *cxelem(int op, P1ND *p);
394 P1ND *cxconj(P1ND *p);
395 P1ND *cxcast(P1ND *p1, P1ND *p2);
396 P1ND *cxret(P1ND *p, P1ND *q);
397 P1ND *imret(P1ND *p, P1ND *q);
398 P1ND *cast(P1ND *p, TWORD t, TWORD q);
399 P1ND *ccast(P1ND *p, TWORD t, TWORD u, union dimfun *df, struct attr *sue);
400 int andable(P1ND *);
401 int conval(P1ND *, int, P1ND *);
402 int ispow2(CONSZ);
403 void defid(P1ND *q, int class);
404 void defid2(P1ND *q, int class, char *astr);
405 void efcode(void);
406 void ecomp(P1ND *p);
407 int upoff(int size, int alignment, int *poff);
408 void nidcl(P1ND *p, int class);
409 void nidcl2(P1ND *p, int class, char *astr);
410 void eprint(P1ND *, int, int *, int *);
411 int uclass(int class);
412 int notlval(P1ND *);
413 void ecode(P1ND *p);
414 void ftnend(void);
415 void dclargs(void);
416 int suemeq(struct attr *s1, struct attr *s2);
417 struct symtab *strmemb(struct attr *ap);
418 int yylex(void);
419 void yyerror(char *);
420 int pragmas_gcc(char *t);
421 int concast(P1ND *p, TWORD t);
422 char *stradd(char *old, char *new);
423 #ifdef WORD_ADDRESSED
424 #define rmpconv(p) (p)
425 #else
426 P1ND *rmpconv(P1ND *);
427 #endif
428 P1ND *optloop(P1ND *);
429 P1ND *nlabel(int label);
430 TWORD styp(void);
431 void *stmtalloc(size_t);
432 void *blkalloc(size_t);
433 void stmtfree(void);
434 void blkfree(void);
435 char *getexname(struct symtab *sp);
436 void putjops(P1ND *p, void *arg);
437 int tnodenr(struct symtab *);
438
439 void p1walkf(P1ND *, void (*f)(P1ND *, void *), void *);
440 void p1fwalk(P1ND *t, void (*f)(P1ND *, int, int *, int *), int down);
441 void p1listf(P1ND *p, void (*f)(P1ND *));
442 void p1flist(P1ND *p, void (*f)(P1ND *, void *), void *);
443 P1ND *p1nfree(P1ND *);
444 void p1tfree(P1ND *);
445 P1ND *p1tcopy(P1ND *);
446
447 struct flt {
448 struct softfloat sf;
449 TWORD t;
450 };
451 typedef struct flt FLT;
452 #define sfallo() stmtalloc(sizeof(struct softfloat))
453
454 struct lexint {
455 CONSZ val;
456 TWORD t;
457 };
458
459 /*
460 * Only allowed to do float evaluation if either doing
461 * static (compile-time) initialization or FP_CONTRACT is YES.
462 */
463 #define CAN_EVAL_FLOAT() (statinit || (flostat & FP_CONTR_CBR))
464 #define FLOAT_ISZERO(p) soft_isz(p)
465 #define FLOAT_NEG(p) soft_neg(p)
466 #define FLOAT_FP2FP(f,t) soft_fp2fp(f, t)
467 #define FLOAT_EQ(d1,d2) soft_cmp(d1, d2, EQ)
468 #define FLOAT_NE(d1,d2) soft_cmp(d1, d2, NE)
469 #define FLOAT_GT(d1,d2) soft_cmp(d1, d2, GT)
470 #define FLOAT_GE(d1,d2) soft_cmp(d1, d2, GE)
471 #define FLOAT_LE(d1,d2) soft_cmp(d1, d2, LE)
472 #define FLOAT_LT(d1,d2) soft_cmp(d1, d2, LT)
473 #define FLOAT_INT2FP(f,p,t) soft_int2fp(f, p, t, ctype(LDOUBLE))
474 #define FLOAT_FP2INT(i,d,t) i = soft_fp2int(d, t)
475 #define FLOAT_PLUS(p1,p2) \
476 soft_plus(p1->n_scon, p2->n_scon, p1->n_type)
477 #define FLOAT_MINUS(p1,p2) \
478 soft_minus(p1->n_scon, p2->n_scon, p1->n_type)
479 #define FLOAT_MUL(p1,p2) \
480 soft_mul(p1->n_scon, p2->n_scon, p1->n_type)
481 #define FLOAT_DIV(p1,p2) \
482 soft_div(p1->n_scon, p2->n_scon, p1->n_type)
483
484 enum { ATTR_FIRST = ATTR_MI_MAX + 1,
485
486 /* PCC used attributes */
487 ATTR_COMPLEX, /* Internal definition of complex */
488 xxxATTR_BASETYP, /* Internal; see below */
489 ATTR_QUALTYP, /* Internal; const/volatile, see below */
490 ATTR_ALIGNED, /* Internal; also used as gcc type attribute */
491 ATTR_NORETURN, /* Function does not return */
492 ATTR_STRUCT, /* Internal; element list */
493 #define ATTR_MAX ATTR_STRUCT
494
495 ATTR_P1LABELS, /* used to store stuff while parsing */
496 ATTR_SONAME, /* output name of symbol */
497
498 #ifdef GCC_COMPAT
499 /* type attributes */
500 GCC_ATYP_PACKED,
501 GCC_ATYP_SECTION,
502 GCC_ATYP_TRANSP_UNION,
503 GCC_ATYP_UNUSED,
504 GCC_ATYP_DEPRECATED,
505 GCC_ATYP_MAYALIAS,
506
507 /* variable attributes */
508 GCC_ATYP_MODE,
509
510 /* function attributes */
511 GCC_ATYP_FORMAT,
512 GCC_ATYP_NONNULL,
513 GCC_ATYP_SENTINEL,
514 GCC_ATYP_WEAK,
515 GCC_ATYP_FORMATARG,
516 GCC_ATYP_GNU_INLINE,
517 GCC_ATYP_MALLOC,
518 GCC_ATYP_NOTHROW,
519 GCC_ATYP_CONST,
520 GCC_ATYP_PURE,
521 GCC_ATYP_CONSTRUCTOR,
522 GCC_ATYP_DESTRUCTOR,
523 GCC_ATYP_VISIBILITY,
524 GCC_ATYP_WARN_UNUSED_RESULT,
525 GCC_ATYP_USED,
526 GCC_ATYP_NO_INSTR_FUN,
527 GCC_ATYP_NOINLINE,
528 GCC_ATYP_ALIAS,
529 GCC_ATYP_WEAKREF,
530 GCC_ATYP_ALLOCSZ,
531 GCC_ATYP_ALW_INL,
532 GCC_ATYP_TLSMODEL,
533 GCC_ATYP_ALIASWEAK,
534 GCC_ATYP_RETURNS_TWICE,
535 GCC_ATYP_WARNING,
536 GCC_ATYP_NOCLONE,
537 GCC_ATYP_REGPARM,
538 GCC_ATYP_FASTCALL,
539
540 /* other stuff */
541 GCC_ATYP_BOUNDED, /* OpenBSD extra boundary checks */
542
543 /* OSX toolchain */
544 GCC_ATYP_WEAKIMPORT,
545
546 GCC_ATYP_MAX,
547 #endif
548 #ifdef ATTR_P1_TARGET
549 ATTR_P1_TARGET,
550 #endif
551 ATTR_P1_MAX
552 };
553
554 /*
555 #ifdef notdef
556 * ATTR_BASETYP has the following layout:
557 * aa[0].iarg has size
558 * aa[1].iarg has alignment
559 #endif
560 * ATTR_QUALTYP has the following layout:
561 * aa[0].iarg has CON/VOL + FUN/ARY/PTR
562 * Not defined yet...
563 * aa[3].iarg is dimension for arrays (XXX future)
564 * aa[3].varg is function defs for functions.
565 */
566 #ifdef notdef
567 #define atypsz aa[0].iarg
568 #define aalign aa[1].iarg
569 #endif
570
571 /*
572 * ATTR_STRUCT member list.
573 */
574 #define amlist aa[0].varg
575 #define amsize aa[1].iarg
576 #define strattr(x) (attr_find(x, ATTR_STRUCT))
577
578 void gcc_init(void);
579 int gcc_keyword(char *);
580 struct attr *gcc_attr_parse(P1ND *);
581 void gcc_tcattrfix(P1ND *);
582 struct gcc_attrib *gcc_get_attr(struct suedef *, int);
583 void dump_attr(struct attr *gap);
584 void gcc_modefix(P1ND *);
585 P1ND *gcc_eval_timode(int op, P1ND *, P1ND *);
586 P1ND *gcc_eval_ticast(int op, P1ND *, P1ND *);
587 P1ND *gcc_eval_tiuni(int op, P1ND *);
588 struct attr *isti(P1ND *p);
589
590 #ifndef NO_C_BUILTINS
591 struct bitable {
592 char *name;
593 P1ND *(*fun)(const struct bitable *, P1ND *a);
594 short flags;
595 #define BTNOPROTO 001
596 #define BTNORVAL 002
597 #define BTNOEVE 004
598 #define BTGNUONLY 010
599 short narg;
600 TWORD *tp;
601 TWORD rt;
602 };
603
604 P1ND *builtin_check(struct symtab *, P1ND *a);
605 void builtin_init(void);
606
607 /* Some builtins targets need to implement */
608 P1ND *builtin_frame_address(const struct bitable *bt, P1ND *a);
609 P1ND *builtin_return_address(const struct bitable *bt, P1ND *a);
610 P1ND *builtin_cfa(const struct bitable *bt, P1ND *a);
611 #endif
612
613
614 #ifdef STABS
615 void stabs_init(void);
616 void stabs_file(char *);
617 void stabs_efile(char *);
618 void stabs_line(int);
619 void stabs_rbrac(int);
620 void stabs_lbrac(int);
621 void stabs_func(struct symtab *);
622 void stabs_newsym(struct symtab *);
623 void stabs_chgsym(struct symtab *);
624 void stabs_struct(struct symtab *, struct attr *);
625 #endif
626 #ifdef DWARF
627 void dwarf_init(char *);
628 void dwarf_file(char *);
629 void dwarf_end(void);
630 #endif
631
632 #ifndef CHARCAST
633 /* to make character constants into character connstants */
634 /* this is a macro to defend against cross-compilers, etc. */
635 #define CHARCAST(x) (char)(x)
636 #endif
637
638 /* sometimes int is smaller than pointers */
639 #if SZPOINT(CHAR) <= SZINT
640 #define INTPTR INT
641 #elif SZPOINT(CHAR) <= SZLONG
642 #define INTPTR LONG
643 #elif SZPOINT(CHAR) <= SZLONGLONG
644 #define INTPTR LONGLONG
645 #else
646 #error int size unknown
647 #endif
648
649 /* Generate a bitmask from a given type size */
650 #define SZMASK(y) ((((1LL << ((y)-1))-1) << 1) | 1)
651
652 /*
653 * finction specifiers.
654 */
655 #define INLINE 1
656 #define NORETURN 2
657
658 /*
659 * C compiler first pass extra defines.
660 */
661 #define QUALIFIER (MAXOP+1)
662 #define CLASS (MAXOP+2)
663 #define RB (MAXOP+3)
664 #define DOT (MAXOP+4)
665 #define ELLIPSIS (MAXOP+5)
666 #define TYPE (MAXOP+6)
667 #define LB (MAXOP+7)
668 #define COMOP (MAXOP+8)
669 #define QUEST (MAXOP+9)
670 #define COLON (MAXOP+10)
671 #define ANDAND (MAXOP+11)
672 #define OROR (MAXOP+12)
673 #define NOT (MAXOP+13)
674 #define CAST (MAXOP+14)
675 #define STRING (MAXOP+15)
676
677 /* The following must be in the same order as their NOASG counterparts */
678 #define PLUSEQ (MAXOP+16)
679 #define MINUSEQ (MAXOP+17)
680 #define DIVEQ (MAXOP+18)
681 #define MODEQ (MAXOP+19)
682 #define MULEQ (MAXOP+20)
683 #define ANDEQ (MAXOP+21)
684 #define OREQ (MAXOP+22)
685 #define EREQ (MAXOP+23)
686 #define LSEQ (MAXOP+24)
687 #define RSEQ (MAXOP+25)
688
689 #define UNASG (-(PLUSEQ-PLUS))+
690
691 #define INCR (MAXOP+26)
692 #define DECR (MAXOP+27)
693 #define SZOF (MAXOP+28)
694 #define CLOP (MAXOP+29)
695 #define ATTRIB (MAXOP+30)
696 #define XREAL (MAXOP+31)
697 #define XIMAG (MAXOP+32)
698 #define TYMERGE (MAXOP+33)
699 #define LABEL (MAXOP+34)
700 #define BIQUEST (MAXOP+35)
701 #define UPLUS (MAXOP+36)
702 #define ALIGN (MAXOP+37)
703 #define FUNSPEC (MAXOP+38)
704 #define STREF (MAXOP+39)
705
706 /*
707 * The following types are only used in pass1.
708 */
709 #define SIGNED (MAXTYPES+1)
710 #define FARG (MAXTYPES+2)
711 #define FIMAG (MAXTYPES+3)
712 #define IMAG (MAXTYPES+4)
713 #define LIMAG (MAXTYPES+5)
714 #define FCOMPLEX (MAXTYPES+6)
715 #define COMPLEX (MAXTYPES+7)
716 #define LCOMPLEX (MAXTYPES+8)
717 #define ENUMTY (MAXTYPES+9)
718
719 #define ISFTY(x) ((x) >= FLOAT && (x) <= LDOUBLE)
720 #define ISCTY(x) ((x) >= FCOMPLEX && (x) <= LCOMPLEX)
721 #define ISITY(x) ((x) >= FIMAG && (x) <= LIMAG)
722 #define ANYCX(p) (p->n_type == STRTY && attr_find(p->n_ap, ATTR_COMPLEX))
723
724 #define coptype(o) (cdope(o)&TYFLG)
725 #define clogop(o) (cdope(o)&LOGFLG)
726 #define casgop(o) (cdope(o)&ASGFLG)
727
728 #ifdef TWOPASS
729 #define PRTPREF "* "
730 #else
731 #define PRTPREF ""
732 #endif
733
734 /*
735 * Allocation routines.
736 */
737 #if defined(__PCC__) || defined(__GNUC__)
738 #define FUNALLO(x) __builtin_alloca(x)
739 #define FUNFREE(x)
740 #elif defined(HAVE_ALLOCA)
741 #define FUNALLO(x) alloca(x)
742 #define FUNFREE(x)
743 #else
744 #define FUNALLO(x) malloc(x)
745 #define FUNFREE(x) free(x)
746 #endif