1 /* $Id: manifest.h,v 1.92 2011/01/22 22:08:54 ragge Exp $ */
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
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
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.
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 */
80 #define XTYPE 17 /* Extended target-specific type */
81 /* #define MOETY 18 */ /* member of enum */
84 #define MAXTYPES 19 /* highest type+1 to be used by lang code */
100 * Type packing constants
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)
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
157 #define CALLFLG 02000
159 #define SHFFLG 010000
160 #define ASGOPFLG 020000
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
;
185 extern int xssaflag
, xtailcallflag
, xtemps
, xdeljumps
, xdce
;
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; \
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; \
246 * Functions for inter-pass communication.
250 DLIST_ENTRY(interpass
) qelem
;
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
283 struct interpass
{ int dummy
; };
284 struct interpass_prolog
;
288 * Epilog/prolog takes following arguments (in order):
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 */
313 void send_passt(int type
, ...);
315 * External declarations, typedefs and the like
318 /* used for memory allocation */
319 typedef struct mark
{
325 /* memory management stuff */
326 void *permalloc(int size
);
327 void *tmpcalloc(int size
);
328 void *tmpalloc(int size
);
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 */
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
*);
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
, ...);
361 extern int nerrors
; /* number of errors seen so far */
362 extern int warniserr
; /* treat warnings as errors */
364 /* gcc warning stuff */
366 #define Wstrict_prototypes 1
367 #define Wmissing_prototypes 2
368 #define Wimplicit_int 3
369 #define Wimplicit_function_declaration 4
371 #define Wpointer_sign 6
372 #define Wsign_compare 7
373 #define Wunknown_pragmas 8
374 #define Wunreachable_code 9
377 void warner(int type
, ...);
378 void Wflags(char *str
);