| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
#ifndef MANIFEST |
| 37 |
#define MANIFEST |
| 38 |
|
| 39 |
#include <stdio.h> |
| 40 |
#include <string.h> |
| 41 |
#include "config.h" |
| 42 |
#include "macdefs.h" |
| 43 |
#include "node.h" |
| 44 |
#include "compat.h" |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
#define LTYPE 02 |
| 50 |
#define UTYPE 04 |
| 51 |
#define BITYPE 010 |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
#define DSIZE (MAXOP+1) |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
#define UNDEF 0 |
| 64 |
#define BOOL 1 |
| 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 |
| 81 |
|
| 82 |
#define VOID 19 |
| 83 |
|
| 84 |
#define MAXTYPES 19 |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
#define NOLAB (-1) |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
#define PTR 0x20 |
| 94 |
#define FTN 0x40 |
| 95 |
#define ARY 0x60 |
| 96 |
#define CON 0x20 |
| 97 |
#define VOL 0x40 |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
#define TMASK 0x060 |
| 103 |
#define TMASK1 0x180 |
| 104 |
#define TMASK2 0x1e0 |
| 105 |
#define BTMASK 0x1f |
| 106 |
#define BTSHIFT 5 |
| 107 |
#define TSHIFT 2 |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
#define MODTYPE(x,y) x = ((x)&(~BTMASK))|(y) |
| 113 |
#define BTYPE(x) ((x)&BTMASK) |
| 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) enunsign(x) |
| 118 |
#define DEUNSIGN(x) deunsign(x) |
| 119 |
#define ISINTEGER(x) ((x) >= BOOL && (x) <= ULONGLONG) |
| 120 |
#define ISPTR(x) (((x)&TMASK)==PTR) |
| 121 |
#define ISFTN(x) (((x)&TMASK)==FTN) |
| 122 |
#define ISARY(x) (((x)&TMASK)==ARY) |
| 123 |
#define ISCON(x) (((x)&CON)==CON) |
| 124 |
#define ISVOL(x) (((x)&VOL)==VOL) |
| 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 |
|
| 131 |
#define NOFIT(x,y,z) (((x)%(z) + (y)) > (z)) |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
#define TARGET_LE 1 |
| 136 |
#define TARGET_BE 2 |
| 137 |
#define TARGET_PDP 3 |
| 138 |
#define TARGET_ANY 4 |
| 139 |
|
| 140 |
#ifndef SPECIAL_INTEGERS |
| 141 |
#define ASGLVAL(lval, val) |
| 142 |
#endif |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
#define PKFIELD(s,o) (((o)<<7)| (s)) |
| 148 |
#define UPKFSZ(v) ((v)&0177) |
| 149 |
#define UPKFOFF(v) ((v)>>7) |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
#define TYFLG 016 |
| 155 |
#define ASGFLG 01 |
| 156 |
#define LOGFLG 020 |
| 157 |
|
| 158 |
#define SIMPFLG 040 |
| 159 |
#define COMMFLG 0100 |
| 160 |
#define DIVFLG 0200 |
| 161 |
#define FLOFLG 0400 |
| 162 |
#define LTYFLG 01000 |
| 163 |
#define CALLFLG 02000 |
| 164 |
#define MULFLG 04000 |
| 165 |
#define SHFFLG 010000 |
| 166 |
#define ASGOPFLG 020000 |
| 167 |
|
| 168 |
#define SPFLG 040000 |
| 169 |
|
| 170 |
#define regno(p) ((p)->n_rval) |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
extern int gflag, kflag, pflag; |
| 176 |
extern int sspflag; |
| 177 |
extern int xscp, xssa, xtailcall, xtemps, xdeljumps, xdce; |
| 178 |
extern int xuchar; |
| 179 |
|
| 180 |
int yyparse(void); |
| 181 |
void yyaccpt(void); |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
#define DLIST_INIT(h,f) { (h)->f.q_forw = (h); (h)->f.q_back = (h); } |
| 189 |
#define DLIST_ENTRY(t) struct { struct t *q_forw, *q_back; } |
| 190 |
#define DLIST_NEXT(h,f) (h)->f.q_forw |
| 191 |
#define DLIST_PREV(h,f) (h)->f.q_back |
| 192 |
#define DLIST_ISEMPTY(h,f) ((h)->f.q_forw == (h)) |
| 193 |
#define DLIST_ENDMARK(h) (h) |
| 194 |
#define DLIST_FOREACH(v,h,f) \ |
| 195 |
for ((v) = (h)->f.q_forw; (v) != (h); (v) = (v)->f.q_forw) |
| 196 |
#define DLIST_FOREACH_REVERSE(v,h,f) \ |
| 197 |
for ((v) = (h)->f.q_back; (v) != (h); (v) = (v)->f.q_back) |
| 198 |
#define DLIST_INSERT_BEFORE(h,e,f) { \ |
| 199 |
(e)->f.q_forw = (h); \ |
| 200 |
(e)->f.q_back = (h)->f.q_back; \ |
| 201 |
(e)->f.q_back->f.q_forw = (e); \ |
| 202 |
(h)->f.q_back = (e); \ |
| 203 |
} |
| 204 |
#define DLIST_INSERT_AFTER(h,e,f) { \ |
| 205 |
(e)->f.q_forw = (h)->f.q_forw; \ |
| 206 |
(e)->f.q_back = (h); \ |
| 207 |
(e)->f.q_forw->f.q_back = (e); \ |
| 208 |
(h)->f.q_forw = (e); \ |
| 209 |
} |
| 210 |
#define DLIST_REMOVE(e,f) { \ |
| 211 |
(e)->f.q_forw->f.q_back = (e)->f.q_back; \ |
| 212 |
(e)->f.q_back->f.q_forw = (e)->f.q_forw; \ |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
#define SLIST_INIT(h) \ |
| 217 |
{ (h)->q_forw = NULL; (h)->q_last = &(h)->q_forw; } |
| 218 |
#define SLIST_SETUP(h) { NULL, &(h)->q_forw } |
| 219 |
#define SLIST_ENTRY(t) struct { struct t *q_forw; } |
| 220 |
#define SLIST_HEAD(n,t) struct n { struct t *q_forw, **q_last; } |
| 221 |
#define SLIST_ISEMPTY(h) ((h)->q_last == &(h)->q_forw) |
| 222 |
#define SLIST_FIRST(h) ((h)->q_forw) |
| 223 |
#define SLIST_FOREACH(v,h,f) \ |
| 224 |
for ((v) = (h)->q_forw; (v) != NULL; (v) = (v)->f.q_forw) |
| 225 |
#define SLIST_INSERT_FIRST(h,e,f) { \ |
| 226 |
if ((h)->q_last == &(h)->q_forw) \ |
| 227 |
(h)->q_last = &(e)->f.q_forw; \ |
| 228 |
(e)->f.q_forw = (h)->q_forw; \ |
| 229 |
(h)->q_forw = (e); \ |
| 230 |
} |
| 231 |
#define SLIST_INSERT_LAST(h,e,f) { \ |
| 232 |
(e)->f.q_forw = NULL; \ |
| 233 |
*(h)->q_last = (e); \ |
| 234 |
(h)->q_last = &(e)->f.q_forw; \ |
| 235 |
} |
| 236 |
|
| 237 |
#ifndef MKEXT |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
struct interpass { |
| 243 |
DLIST_ENTRY(interpass) qelem; |
| 244 |
int type; |
| 245 |
int lineno; |
| 246 |
union { |
| 247 |
NODE *_p; |
| 248 |
int _locctr; |
| 249 |
int _label; |
| 250 |
int _curoff; |
| 251 |
char *_name; |
| 252 |
} _un; |
| 253 |
}; |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
struct interpass_prolog { |
| 261 |
struct interpass ipp_ip; |
| 262 |
char *ipp_name; |
| 263 |
int ipp_vis; |
| 264 |
TWORD ipp_type; |
| 265 |
int ipp_autos; |
| 266 |
int ip_tmpnum; |
| 267 |
int ip_lblnum; |
| 268 |
int *ip_labels; |
| 269 |
#ifdef TARGET_IPP_MEMBERS |
| 270 |
TARGET_IPP_MEMBERS |
| 271 |
#endif |
| 272 |
}; |
| 273 |
#else |
| 274 |
struct interpass { int dummy; }; |
| 275 |
struct interpass_prolog; |
| 276 |
#endif |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
#define ip_node _un._p |
| 289 |
#define ip_locc _un._locctr |
| 290 |
#define ip_lbl _un._label |
| 291 |
#define ip_name _un._name |
| 292 |
#define ip_asm _un._name |
| 293 |
#define ip_off _un._curoff |
| 294 |
|
| 295 |
|
| 296 |
#define IP_NODE 1 |
| 297 |
#define IP_PROLOG 2 |
| 298 |
#define IP_EPILOG 4 |
| 299 |
#define IP_DEFLAB 5 |
| 300 |
#define IP_DEFNAM 6 |
| 301 |
#define IP_ASM 7 |
| 302 |
#define MAXIP 7 |
| 303 |
|
| 304 |
void send_passt(int type, ...); |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
enum { |
| 311 |
ATTR_NONE, |
| 312 |
ATTR_FP_SWAPPED, |
| 313 |
#ifdef GCC_COMPAT |
| 314 |
GCC_ATYP_STDCALL, |
| 315 |
GCC_ATYP_CDECL, |
| 316 |
#endif |
| 317 |
#ifdef ATTR_MI_TARGET |
| 318 |
ATTR_MI_TARGET, |
| 319 |
#endif |
| 320 |
ATTR_MI_MAX |
| 321 |
}; |
| 322 |
|
| 323 |
struct attr *attr_add(struct attr *orig, struct attr *new); |
| 324 |
struct attr *attr_new(int, int); |
| 325 |
struct attr *attr_find(struct attr *, int); |
| 326 |
struct attr *attr_copy(struct attr *src, struct attr *dst, int nelem); |
| 327 |
struct attr *attr_dup(struct attr *ap); |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
typedef struct mark { |
| 335 |
void *tmsav; |
| 336 |
void *tasav; |
| 337 |
int elem; |
| 338 |
} MARK; |
| 339 |
|
| 340 |
|
| 341 |
void *permalloc(size_t); |
| 342 |
void *tmpcalloc(size_t); |
| 343 |
void *tmpalloc(size_t); |
| 344 |
void tmpfree(void); |
| 345 |
char *newstring(char *, size_t); |
| 346 |
char *tmpstrdup(char *str); |
| 347 |
void markset(struct mark *m); |
| 348 |
void markfree(struct mark *m); |
| 349 |
void *xmalloc(int size); |
| 350 |
void *xcalloc(int a, int b); |
| 351 |
void *xstrdup(char *s); |
| 352 |
|
| 353 |
int getlab(void); |
| 354 |
|
| 355 |
|
| 356 |
void mflags(char *); |
| 357 |
|
| 358 |
void tprint(TWORD, TWORD); |
| 359 |
|
| 360 |
|
| 361 |
void topt_compile(struct interpass *); |
| 362 |
|
| 363 |
|
| 364 |
void pass2_compile(struct interpass *); |
| 365 |
|
| 366 |
|
| 367 |
NODE *nfree(NODE *); |
| 368 |
void tfree(NODE *); |
| 369 |
NODE *tcopy(NODE *); |
| 370 |
void walkf(NODE *, void (*f)(NODE *, void *), void *); |
| 371 |
void fwalk(NODE *t, void (*f)(NODE *, int, int *, int *), int down); |
| 372 |
void flist(NODE *p, void (*f)(NODE *, void *), void *); |
| 373 |
void listf(NODE *p, void (*f)(NODE *)); |
| 374 |
NODE *listarg(NODE *p, int n, int *cnt); |
| 375 |
void cerror(const char *s, ...); |
| 376 |
void werror(const char *s, ...); |
| 377 |
void uerror(const char *s, ...); |
| 378 |
void mkdope(void); |
| 379 |
void tcheck(void); |
| 380 |
|
| 381 |
extern int nerrors; |
| 382 |
extern int warniserr; |
| 383 |
|
| 384 |
|
| 385 |
#define Wtruncate 0 |
| 386 |
#define Wstrict_prototypes 1 |
| 387 |
#define Wmissing_prototypes 2 |
| 388 |
#define Wimplicit_int 3 |
| 389 |
#define Wimplicit_function_declaration 4 |
| 390 |
#define Wshadow 5 |
| 391 |
#define Wpointer_sign 6 |
| 392 |
#define Wsign_compare 7 |
| 393 |
#define Wunknown_pragmas 8 |
| 394 |
#define Wunreachable_code 9 |
| 395 |
#define Wdeprecated_declarations 10 |
| 396 |
#define Wattributes 11 |
| 397 |
#define Wuninitialized 12 |
| 398 |
|
| 399 |
void warner(int type, ...); |
| 400 |
int Wset(char *, int, int); |
| 401 |
void Wflags(char *); |
| 402 |
TWORD deunsign(TWORD t); |
| 403 |
TWORD enunsign(TWORD t); |
| 404 |
#endif |