|
|
1.1 root 1: /* @(#) manifest.h: 1.4 3/26/84 */
2:
3:
4: # include <stdio.h>
5:
6: /* macro definitions for common cases of type collapsing */
7: # ifdef NOSHORT
8: # define SZSHORT SZINT
9: # define ALSHORT ALINT
10: # endif
11:
12: # ifdef NOLONG
13: # define SZLONG SZINT
14: # define ALLONG ALINT
15: # endif
16:
17: # ifdef NOFLOAT
18: # define SZFLOAT SZLONG
19: # define SZDOUBLE SZLONG
20: # define ALFLOAT ALLONG
21: # define ALDOUBLE ALLONG
22: # endif
23:
24: # ifdef ONEFLOAT
25: # define SZFLOAT SZDOUBLE
26: # define ALFLOAT ALDOUBLE
27: # endif
28:
29: /* define default assembly language comment starter */
30:
31: # ifndef COMMENTSTR
32: # define COMMENTSTR "#"
33: #endif
34:
35: /* manifest constant file for the lex/yacc interface */
36:
37: # define ERROR 1
38: # define NAME 2
39: # define STRING 3
40: # define ICON 4
41: # define FCON 5
42: # define PLUS 6
43: # define MINUS 8
44: # define MUL 11
45: # define STAR (UNARY MUL)
46: # define AND 14
47: # define OR 17
48: # define ER 19
49: # define QUEST 21
50: # define COLON 22
51: # define ANDAND 23
52: # define OROR 24
53:
54: /* special interfaces for yacc alone */
55: /* These serve as abbreviations of 2 or more ops:
56: ASOP =, = ops
57: RELOP LE,LT,GE,GT
58: EQUOP EQ,NE
59: DIVOP DIV,MOD
60: SHIFTOP LS,RS
61: ICOP INCR,DECR
62: UNOP NOT,COMPL
63: STROP DOT,STREF
64:
65: */
66: # define ASOP 25
67: # define RELOP 26
68: # define EQUOP 27
69: # define DIVOP 28
70: # define SHIFTOP 29
71: # define INCOP 30
72: # define UNOP 31
73: # define STROP 32
74:
75: /* reserved words, etc */
76: # define TYPE 33
77: # define CLASS 34
78: # define STRUCT 35
79: # define RETURN 36
80: # define GOTO 37
81: # define IF 38
82: # define ELSE 39
83: # define SWITCH 40
84: # define BREAK 41
85: # define CONTINUE 42
86: # define WHILE 43
87: # define DO 44
88: # define FOR 45
89: # define DEFAULT 46
90: # define CASE 47
91: # define SIZEOF 48
92: # define ENUM 49
93:
94: /* little symbols, etc. */
95: /* namely,
96:
97: LP (
98: RP )
99:
100: LC {
101: RC }
102:
103: LB [
104: RB ]
105:
106: CM ,
107: SM ;
108:
109: */
110:
111: # define LP 50
112: # define RP 51
113: # define LC 52
114: # define RC 53
115: # define LB 54
116: # define RB 55
117: # define CM 56
118: # define SM 57
119: # define ASSIGN 58
120: /* ASM returned only by yylex, and totally eaten by yyparse */
121: # define ASM 59
122:
123: /* END OF YACC */
124:
125: /* left over tree building operators */
126: # define COMOP 59
127: # define DIV 60
128: # define MOD 62
129: # define LS 64
130: # define RS 66
131: # define DOT 68
132: # define STREF 69
133: # define CALL 70
134: # define FORTCALL 73
135: # define NOT 76
136: # define COMPL 77
137: # define INCR 78
138: # define DECR 79
139: # define EQ 80
140: # define NE 81
141: # define LE 82
142: # define LT 83
143: # define GE 84
144: # define GT 85
145: # define ULE 86
146: # define ULT 87
147: # define UGE 88
148: # define UGT 89
149: # define SETBIT 90
150: # define TESTBIT 91
151: # define RESETBIT 92
152: # define ARS 93
153: # define REG 94
154: # define TEMP 95
155: # define CCODES 96
156: # define FREE 97
157: # define STASG 98
158: # define STARG 99
159: # define STCALL 100
160:
161: /* some conversion operators */
162: # define FLD 103
163: # define CONV 104
164: # define PMUL 105
165: # define PDIV 106
166:
167: /* special node operators, used for special contexts */
168: /* # define FORCE 107 */
169: # define GENLAB 108
170: # define CBRANCH 109
171: # define GENBR 110
172: # define CMP 111
173: # define GENUBR 112
174: # define INIT 113
175: # define CAST 114
176: # define FUNARG 115
177: # define VAUTO 116
178: # define VPARAM 117
179: # define RNODE 118
180: # define SNODE 119
181: # define QNODE 120
182: /* a whole bunch of ops, done with unary; I don't need to tackle prec */
183: # define UOP0 121
184: # define UOP1 122
185: # define UOP2 123
186: # define UOP3 124
187: # define UOP4 125
188: # define UOP5 126
189: # define UOP6 127
190: # define UOP7 128
191: # define UOP8 129
192: # define UOP9 130
193: /* op used in second pass */
194: # define MANY 131
195:
196: /* node types */
197: # define LTYPE 02
198: # define UTYPE 04
199: # define BITYPE 010
200:
201: /* DSIZE is the size of the dope array */
202: # define DSIZE MANY+1
203:
204: /* type names, used in symbol table building */
205: # define TNULL 0
206: # define FARG 1
207: # define CHAR 2
208: # define SHORT 3
209: # define INT 4
210: # define LONG 5
211: # define FLOAT 6
212: # define DOUBLE 7
213: # define STRTY 8
214: # define UNIONTY 9
215: # define ENUMTY 10
216: # define MOETY 11
217: # define UCHAR 12
218: # define USHORT 13
219: # define UNSIGNED 14
220: # define ULONG 15
221: # define VOID 16
222: # define UNDEF 17
223:
224: # define ASG 1+
225: # define UNARY 2+
226: # define NOASG (-1)+
227: # define NOUNARY (-2)+
228:
229: /* various flags */
230: # define NOLAB (-1)
231:
232: /* type modifiers */
233:
234: # define PTR 040
235: # define FTN 0100
236: # define ARY 0140
237:
238: /* type packing constants */
239:
240: # define MTMASK 03
241: # define BTMASK 037
242: # define BTSHIFT 5
243: # define TSHIFT 2
244: # define TMASK (MTMASK<<BTSHIFT)
245: # define TMASK1 (MTMASK<<(BTSHIFT+TSHIFT))
246: # define TMASK2 (TMASK||MTMASK)
247:
248: /* macros */
249:
250: # ifndef BITMASK
251: /* beware 1's complement */
252: # define BITMASK(n) (((n)==SZLONG)?-1L:((1L<<(n))-1))
253: # endif
254: # define ONEBIT(n) (1L<<(n))
255: # define MODTYPE(x,y) x = (x&(~BTMASK))|y /* set basic type of x to y */
256: # define BTYPE(x) (x&BTMASK) /* basic type of x */
257: # define ISUNSIGNED(x) ((x)<=ULONG&&(x)>=UCHAR)
258: # define UNSIGNABLE(x) ((x)<=LONG&&(x)>=CHAR)
259: # define ENUNSIGN(x) ((x)+(UNSIGNED-INT))
260: # define DEUNSIGN(x) ((x)+(INT-UNSIGNED))
261: # define ISPTR(x) ((x&TMASK)==PTR)
262: # define ISFTN(x) ((x&TMASK)==FTN) /* is x a function type */
263: # define ISARY(x) ((x&TMASK)==ARY) /* is x an array type */
264: # define INCREF(x) (((x&~BTMASK)<<TSHIFT)|PTR|(x&BTMASK))
265: # define DECREF(x) (((x>>TSHIFT)&~BTMASK)|(x&BTMASK))
266: # define SETOFF(x,y) if( (x)%(y) != 0 ) x = ( ((x)/(y) + 1) * (y))
267: /* advance x to a multiple of y */
268: # define NOFIT(x,y,z) ( ((x)%(z) + (y)) > (z) )
269: /* can y bits be added to x without overflowing z */
270: /* pack and unpack field descriptors (size and offset) */
271: # define PKFIELD(s,o) (((o)<<6)|(s))
272: # define UPKFSZ(v) ((v)&077)
273: # define UPKFOFF(v) ((v)>>6)
274:
275: /* operator information */
276:
277: # define TYFLG 016
278: # define ASGFLG 01
279: # define LOGFLG 020
280:
281: # define SIMPFLG 040
282: # define COMMFLG 0100
283: # define DIVFLG 0200
284: # define FLOFLG 0400
285: # define LTYFLG 01000
286: # define CALLFLG 02000
287: # define MULFLG 04000
288: # define SHFFLG 010000
289: # define ASGOPFLG 020000
290:
291: # define SPFLG 040000
292:
293: #define optype(o) (dope[o]&TYFLG)
294: #define asgop(o) (dope[o]&ASGFLG)
295: #define asgbinop(o) (dope[o]&ASGOPFLG)
296: #define logop(o) (dope[o]&LOGFLG)
297: #define callop(o) (dope[o]&CALLFLG)
298:
299: /* table sizes */
300:
301: #ifdef M32B
302: # define BCSZ 125 /* size of the table to save break and continue labels */
303: #else
304: # define BCSZ 100 /* size of the table to save break and continue labels */
305: #endif
306: # define MAXNEST BCSZ /* maximum nesting depth (for scopestack) */
307: # ifndef SYMTSZ
308: # define SYMTSZ 1100 /* size of the symbol table */
309: # endif
310: # define DIMTABSZ 1500 /* size of the dimension/size table */
311: # define PARAMSZ 150 /* size of the parameter stack */
312: # define ARGSZ 50 /* size of the argument stack */
313: # ifndef TREESZ
314: # ifndef FORT
315: # define TREESZ 370 /* space for building parse tree */
316: # else
317: # define TREESZ 1000
318: # endif
319: # endif
320: # define SWITSZ 250 /* size of switch table */
321:
322: char *hash();
323: char *savestr();
324: char *tstr();
325: extern int tstrused;
326: extern char *tstrbuf[];
327: extern char **curtstr;
328: #define freestr() ( curtstr = tstrbuf, tstrused = 0 )
329:
330: # define NCHNAM 8 /* number of characters in a truncated name */
331:
332: /* common defined variables */
333:
334: extern int nerrors; /* number of errors seen so far */
335:
336: typedef union ndu NODE;
337: typedef unsigned int TWORD;
338: typedef long CONSZ; /* size in which constants are converted */
339:
340: /* default is byte addressing */
341: /* BITOOR(x) converts bit width x into address offset */
342: # ifndef BITOOR
343: # define BITOOR(x) ((x)/SZCHAR)
344: # endif
345:
346: # ifdef SDB
347: # define STABS
348: # endif
349:
350: #if defined(TMPSRET) && !defined(AUXREG)
351: #define AUXREG (NRGS - 1)
352: #endif
353:
354: # define NIL (NODE *)0
355:
356: extern int dope[]; /* a vector containing operator information */
357: extern char *opst[]; /* a vector containing names for ops */
358:
359: # define NCOSTS (NRGS+4)
360:
361: /* in one-pass operation, define the tree nodes */
362:
363: union ndu {
364:
365: struct {
366: int op;
367: int goal;
368: TWORD type;
369: int cst[NCOSTS];
370: char * name;
371: char pad[NCHNAM-sizeof(char *)]; /* padding hack! */
372: NODE *left;
373: NODE *right;
374: }in; /* interior node */
375:
376: struct {
377: int op;
378: int goal;
379: TWORD type;
380: int cst[NCOSTS];
381: char * name;
382: char pad[NCHNAM-sizeof(char *)]; /* padding hack! */
383: CONSZ lval;
384: int rval;
385: }tn; /* terminal node */
386:
387: struct {
388: int op;
389: int goal;
390: TWORD type;
391: int cst[NCOSTS];
392: int label; /* for use with branching */
393: int lop; /* the opcode being branched on */
394: }bn; /* branch node */
395:
396: struct {
397: int op;
398: int goal;
399: TWORD type;
400: int cst[NCOSTS];
401: int stsize; /* sizes of structure objects */
402: short stalign; /* alignment of structure objects */
403: short argsize; /* size of argument list for call */
404: }stn; /* structure node */
405:
406: struct {
407: int op;
408: int goal;
409: TWORD type;
410: int cdim;
411: int csiz;
412: }fn; /* front node */
413:
414: struct {
415: /* this structure is used when a floating point constant
416: is being computed */
417: int op;
418: int goal;
419: TWORD type;
420: int cdim;
421: int csiz;
422: double dval;
423: }fpn; /* floating point node */
424:
425: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.