* add p cc
[mascara-docs.git] / compilers / pcc / pcc-1.0.0 / mip / manifest.h
blobb6035e06d49c7c2fd6bd294948fdc47b9b644b48
1 /* $Id: manifest.h,v 1.92 2011/01/22 22:08:54 ragge Exp $ */
2 /*
3 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
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.
36 #ifndef MANIFEST
37 #define MANIFEST
39 #include <stdio.h>
40 #include <string.h>
41 #include "config.h"
42 #include "macdefs.h"
43 #include "node.h"
44 #include "compat.h"
47 * Node types
49 #define LTYPE 02 /* leaf */
50 #define UTYPE 04 /* unary */
51 #define BITYPE 010 /* binary */
54 * DSIZE is the size of the dope array
56 #define DSIZE (MAXOP+1)
59 * Type names, used in symbol table building.
60 * The order of the integer types are important.
61 * Signed types must have bit 0 unset, unsigned types set (used below).
63 #define UNDEF 0 /* free symbol table entry */
64 #define FARG 1 /* function argument */
65 #define CHAR 2
66 #define UCHAR 3
67 #define SHORT 4
68 #define USHORT 5
69 #define INT 6
70 #define UNSIGNED 7
71 #define LONG 8
72 #define ULONG 9
73 #define LONGLONG 10
74 #define ULONGLONG 11
75 #define FLOAT 12
76 #define DOUBLE 13
77 #define LDOUBLE 14
78 #define STRTY 15
79 #define UNIONTY 16
80 #define XTYPE 17 /* Extended target-specific type */
81 /* #define MOETY 18 */ /* member of enum */
82 #define VOID 19
84 #define MAXTYPES 19 /* highest type+1 to be used by lang code */
86 * Various flags
88 #define NOLAB (-1)
90 /*
91 * Type modifiers.
93 #define PTR 0x20
94 #define FTN 0x40
95 #define ARY 0x60
96 #define CON 0x20
97 #define VOL 0x40
100 * Type packing constants
102 #define TMASK 0x060
103 #define TMASK1 0x180
104 #define TMASK2 0x1e0
105 #define BTMASK 0x1f
106 #define BTSHIFT 5
107 #define TSHIFT 2
110 * Macros
112 #define MODTYPE(x,y) x = ((x)&(~BTMASK))|(y) /* set basic type of x to y */
113 #define BTYPE(x) ((x)&BTMASK) /* basic type of x */
114 #define ISLONGLONG(x) ((x) == LONGLONG || (x) == ULONGLONG)
115 #define ISUNSIGNED(x) (((x) <= ULONGLONG) && (((x) & 1) == (UNSIGNED & 1)))
116 #define UNSIGNABLE(x) (((x)<=ULONGLONG&&(x)>=CHAR) && !ISUNSIGNED(x))
117 #define ENUNSIGN(x) ((x)|1)
118 #define DEUNSIGN(x) ((x)&~1)
119 #define ISINTEGER(x) (((x) >= CHAR && (x) <= ULONGLONG) || (x) == BOOL)
120 #define ISPTR(x) (((x)&TMASK)==PTR)
121 #define ISFTN(x) (((x)&TMASK)==FTN) /* is x a function type? */
122 #define ISARY(x) (((x)&TMASK)==ARY) /* is x an array type? */
123 #define ISCON(x) (((x)&CON)==CON) /* is x const? */
124 #define ISVOL(x) (((x)&VOL)==VOL) /* is x volatile? */
125 #define INCREF(x) ((((x)&~BTMASK)<<TSHIFT)|PTR|((x)&BTMASK))
126 #define INCQAL(x) ((((x)&~BTMASK)<<TSHIFT)|((x)&BTMASK))
127 #define DECREF(x) ((((x)>>TSHIFT)&~BTMASK)|((x)&BTMASK))
128 #define DECQAL(x) ((((x)>>TSHIFT)&~BTMASK)|((x)&BTMASK))
129 #define SETOFF(x,y) { if ((x)%(y) != 0) (x) = (((x)/(y) + 1) * (y)); }
130 /* advance x to a multiple of y */
131 #define NOFIT(x,y,z) (((x)%(z) + (y)) > (z))
132 /* can y bits be added to x without overflowing z */
134 #ifndef SPECIAL_INTEGERS
135 #define ASGLVAL(lval, val)
136 #endif
139 * Pack and unpack field descriptors (size and offset)
141 #define PKFIELD(s,o) (((o)<<7)| (s))
142 #define UPKFSZ(v) ((v)&0177)
143 #define UPKFOFF(v) ((v)>>7)
146 * Operator information
148 #define TYFLG 016
149 #define ASGFLG 01
150 #define LOGFLG 020
152 #define SIMPFLG 040
153 #define COMMFLG 0100
154 #define DIVFLG 0200
155 #define FLOFLG 0400
156 #define LTYFLG 01000
157 #define CALLFLG 02000
158 #define MULFLG 04000
159 #define SHFFLG 010000
160 #define ASGOPFLG 020000
162 #define SPFLG 040000
165 * Location counters
167 #define PROG 0 /* (ro) program segment */
168 #define DATA 1 /* (rw) data segment */
169 #define RDATA 2 /* (ro) data segment */
170 #define STRNG 3 /* (ro) string segment */
171 #define UDATA 4 /* (rw) uninitialized data */
174 #define regno(p) ((p)->n_rval) /* register number */
179 extern int bdebug, tdebug, edebug;
180 extern int ddebug, xdebug, f2debug;
181 extern int iTflag, oTflag, kflag;
182 extern int sflag, nflag, gflag, pflag;
183 extern int funsigned_char;
184 extern int sspflag;
185 extern int xssaflag, xtailcallflag, xtemps, xdeljumps, xdce;
187 int yyparse(void);
188 void yyaccpt(void);
191 * List handling macros, similar to those in 4.4BSD.
192 * The double-linked list is insque-style.
194 /* Double-linked list macros */
195 #define DLIST_INIT(h,f) { (h)->f.q_forw = (h); (h)->f.q_back = (h); }
196 #define DLIST_ENTRY(t) struct { struct t *q_forw, *q_back; }
197 #define DLIST_NEXT(h,f) (h)->f.q_forw
198 #define DLIST_PREV(h,f) (h)->f.q_back
199 #define DLIST_ISEMPTY(h,f) ((h)->f.q_forw == (h))
200 #define DLIST_ENDMARK(h) (h)
201 #define DLIST_FOREACH(v,h,f) \
202 for ((v) = (h)->f.q_forw; (v) != (h); (v) = (v)->f.q_forw)
203 #define DLIST_FOREACH_REVERSE(v,h,f) \
204 for ((v) = (h)->f.q_back; (v) != (h); (v) = (v)->f.q_back)
205 #define DLIST_INSERT_BEFORE(h,e,f) { \
206 (e)->f.q_forw = (h); \
207 (e)->f.q_back = (h)->f.q_back; \
208 (e)->f.q_back->f.q_forw = (e); \
209 (h)->f.q_back = (e); \
211 #define DLIST_INSERT_AFTER(h,e,f) { \
212 (e)->f.q_forw = (h)->f.q_forw; \
213 (e)->f.q_back = (h); \
214 (e)->f.q_forw->f.q_back = (e); \
215 (h)->f.q_forw = (e); \
217 #define DLIST_REMOVE(e,f) { \
218 (e)->f.q_forw->f.q_back = (e)->f.q_back; \
219 (e)->f.q_back->f.q_forw = (e)->f.q_forw; \
222 /* Single-linked list */
223 #define SLIST_INIT(h) \
224 { (h)->q_forw = NULL; (h)->q_last = &(h)->q_forw; }
225 #define SLIST_SETUP(h) { NULL, &(h)->q_forw }
226 #define SLIST_ENTRY(t) struct { struct t *q_forw; }
227 #define SLIST_HEAD(n,t) struct n { struct t *q_forw, **q_last; }
228 #define SLIST_ISEMPTY(h) ((h)->q_last == &(h)->q_forw)
229 #define SLIST_FIRST(h) ((h)->q_forw)
230 #define SLIST_FOREACH(v,h,f) \
231 for ((v) = (h)->q_forw; (v) != NULL; (v) = (v)->f.q_forw)
232 #define SLIST_INSERT_FIRST(h,e,f) { \
233 if ((h)->q_last == &(h)->q_forw) \
234 (h)->q_last = &(e)->f.q_forw; \
235 (e)->f.q_forw = (h)->q_forw; \
236 (h)->q_forw = (e); \
238 #define SLIST_INSERT_LAST(h,e,f) { \
239 (e)->f.q_forw = NULL; \
240 *(h)->q_last = (e); \
241 (h)->q_last = &(e)->f.q_forw; \
244 #ifndef MKEXT
246 * Functions for inter-pass communication.
249 struct interpass {
250 DLIST_ENTRY(interpass) qelem;
251 int type;
252 int lineno;
253 union {
254 NODE *_p;
255 int _locctr;
256 int _label;
257 int _curoff;
258 char *_name;
259 } _un;
263 * Special struct for prologue/epilogue.
264 * - ip_lblnum contains the lowest/highest+1 label used
265 * - ip_lbl is set before/after all code and after/before the prolog/epilog.
267 struct interpass_prolog {
268 struct interpass ipp_ip;
269 char *ipp_name; /* Function name */
270 int ipp_vis; /* Function visibility */
271 TWORD ipp_type; /* Function type */
272 #define NIPPREGS BIT2BYTE(MAXREGS)/sizeof(bittype)
273 bittype ipp_regs[NIPPREGS];
274 /* Bitmask of registers to save */
275 int ipp_autos; /* Size on stack needed */
276 int ip_tmpnum; /* # allocated temp nodes so far */
277 int ip_lblnum; /* # used labels so far */
278 #ifdef TARGET_IPP_MEMBERS
279 TARGET_IPP_MEMBERS
280 #endif
282 #else
283 struct interpass { int dummy; };
284 struct interpass_prolog;
285 #endif /* !MKEXT */
288 * Epilog/prolog takes following arguments (in order):
289 * - type
290 * - regs
291 * - autos
292 * - name
293 * - type
294 * - retlab
297 #define ip_node _un._p
298 #define ip_locc _un._locctr
299 #define ip_lbl _un._label
300 #define ip_name _un._name
301 #define ip_asm _un._name
302 #define ip_off _un._curoff
304 /* Types of inter-pass structs */
305 #define IP_NODE 1
306 #define IP_PROLOG 2
307 #define IP_EPILOG 4
308 #define IP_DEFLAB 5
309 #define IP_DEFNAM 6
310 #define IP_ASM 7
311 #define MAXIP 7
313 void send_passt(int type, ...);
315 * External declarations, typedefs and the like
318 /* used for memory allocation */
319 typedef struct mark {
320 void *tmsav;
321 void *tasav;
322 int elem;
323 } MARK;
325 /* memory management stuff */
326 void *permalloc(int size);
327 void *tmpcalloc(int size);
328 void *tmpalloc(int size);
329 void tmpfree(void);
330 char *newstring(char *, int len);
331 char *tmpstrdup(char *str);
332 void markset(struct mark *m);
333 void markfree(struct mark *m);
335 /* command-line processing */
336 void mflags(char *);
338 void tprint(FILE *, TWORD, TWORD);
340 /* pass t communication subroutines */
341 void topt_compile(struct interpass *);
343 /* pass 2 communication subroutines */
344 void pass2_compile(struct interpass *);
346 /* node routines */
347 NODE *nfree(NODE *);
348 void tfree(NODE *);
349 NODE *tcopy(NODE *);
350 void walkf(NODE *, void (*f)(NODE *, void *), void *);
351 void fwalk(NODE *t, void (*f)(NODE *, int, int *, int *), int down);
352 void flist(NODE *p, void (*f)(NODE *, void *), void *);
353 void listf(NODE *p, void (*f)(NODE *));
354 NODE *listarg(NODE *p, int n, int *cnt);
355 void cerror(char *s, ...);
356 void werror(char *s, ...);
357 void uerror(char *s, ...);
358 void mkdope(void);
359 void tcheck(void);
361 extern int nerrors; /* number of errors seen so far */
362 extern int warniserr; /* treat warnings as errors */
364 /* gcc warning stuff */
365 #define Wtruncate 0
366 #define Wstrict_prototypes 1
367 #define Wmissing_prototypes 2
368 #define Wimplicit_int 3
369 #define Wimplicit_function_declaration 4
370 #define Wshadow 5
371 #define Wpointer_sign 6
372 #define Wsign_compare 7
373 #define Wunknown_pragmas 8
374 #define Wunreachable_code 9
375 #define NUMW 10
377 void warner(int type, ...);
378 void Wflags(char *str);
380 #endif