|
|
1.1 root 1: /* @(#)mip.h 1.1 86/02/03 SMI */
2:
3:
4: # include <stdio.h>
5: /* manifest constant file for the lex/yacc interface */
6:
7: # define ERROR 1
8: # define NAME 2
9: # define STRING 3
10: # define ICON 4
11: # define FCON 5
12: # define PLUS 6
13: # define MINUS 8
14: # define MUL 11
15: # define AND 14
16: # define OR 17
17: # define ER 19
18: # define QUEST 21
19: # define COLON 22
20: # define ANDAND 23
21: # define OROR 24
22:
23: /* the defines for ASOP, RELOP, EQUOP, DIVOP,
24: SHIFTOP, ICOP, UNOP, and STROP have been
25: moved to mfile1 */
26: /* reserved words, etc */
27: # define TYPE 33
28: # define CLASS 34
29: # define STRUCT 35
30: # define RETURN 36
31: # define GOTO 37
32: # define IF 38
33: # define ELSE 39
34: # define SWITCH 40
35: # define BREAK 41
36: # define CONTINUE 42
37: # define WHILE 43
38: # define DO 44
39: # define FOR 45
40: # define DEFAULT 46
41: # define CASE 47
42: # define SIZEOF 48
43: # define ENUM 49
44:
45:
46: /* little symbols, etc. */
47: /* namely,
48:
49: LP (
50: RP )
51:
52: LC {
53: RC }
54:
55: LB [
56: RB ]
57:
58: CM ,
59: SM ;
60:
61: */
62:
63: /* These defines are being moved to mfile1
64: to alleviate preprocessor problems with
65: second pass files.
66: # define LP 50
67: # define RP 51
68: # define LC 52
69: # define RC 53
70: */
71: # define LB 54
72: # define RB 55
73: # define CM 56
74: # define SM 57
75: # define ASSIGN 58
76: /* ASM out of order */
77: # define ASM 112
78:
79: /* END OF YACC */
80:
81: /* left over tree building operators */
82: # define COMOP 59
83: # define DIV 60
84: # define MOD 62
85: # define LS 64
86: # define RS 66
87: # define DOT 68
88: # define STREF 69
89: # define CALL 70
90: # define FORTCALL 73
91: # define NOT 76
92: # define COMPL 77
93: # define INCR 78
94: # define DECR 79
95: # define EQ 80
96: # define NE 81
97: # define LE 82
98: # define LT 83
99: # define GE 84
100: # define GT 85
101: # define ULE 86
102: # define ULT 87
103: # define UGE 88
104: # define UGT 89
105: # define SETBIT 90
106: # define TESTBIT 91
107: # define RESETBIT 92
108: # define ARS 93
109: # define REG 94
110: # define OREG 95
111: # define CCODES 96
112: # define FREE 97
113: # define STASG 98
114: # define STARG 99
115: # define STCALL 100
116:
117: /* some conversion operators */
118: # define FLD 103
119: # define SCONV 104
120: # define PCONV 105
121: # define PMCONV 106
122: # define PVCONV 107
123:
124: /* special node operators, used for special contexts */
125: # define FORCE 108
126: # define CBRANCH 109
127: # define INIT 110
128: # define CAST 111
129: /* ASM 112 */
130: # define FCCODES 113
131: # define CHK 114
132:
133: /* fortran intrinsics */
134: # define FABS 115 /* y = abs(x) */
135: # define FCOS 116 /* y = cos(x) */
136: # define FSIN 117 /* y = sin(x) */
137: # define FTAN 118 /* y = tan(x) */
138: # define FACOS 119 /* y = arccos(x) */
139: # define FASIN 120 /* y = arcsin(x) */
140: # define FATAN 121 /* y = arctan(x) */
141: # define FCOSH 122 /* y = cosh(x) */
142: # define FSINH 123 /* y = sinh(x) */
143: # define FTANH 124 /* y = tanh(x) */
144: # define FEXP 125 /* y = e**x */
145: # define F10TOX 126 /* y = 10**x */
146: # define F2TOX 127 /* y = 2**x */
147: # define FLOGN 128 /* y = log_base_e(x) */
148: # define FLOG10 129 /* y = log_base_10(x) */
149: # define FLOG2 130 /* y = log_base_2(x) */
150: # define FSQR 131 /* y = sqr(x) */
151: # define FSQRT 132 /* y = sqrt(x) */
152: # define FAINT 133 /* y = aint(x) */
153: # define FANINT 134 /* y = anint(x) */
154: # define FNINT 135 /* n = nint(x) */
155:
156: /* DSIZE is the size of the dope array (last op + 1) */
157: # define DSIZE 136
158:
159: /* node types */
160: # define LTYPE 02
161: # define UTYPE 04
162: # define BITYPE 010
163:
164: /* type names, used in symbol table building */
165: # define TNULL PTR /* pointer to UNDEF */
166: # define TVOID FTN /* function returning UNDEF (for void) */
167: # define UNDEF 0
168: # define FARG 1
169: # define CHAR 2
170: # define SHORT 3
171: # define INT 4
172: # define LONG 5
173: # define FLOAT 6
174: # define DOUBLE 7
175: # define STRTY 8
176: # define UNIONTY 9
177: # define ENUMTY 10
178: # define MOETY 11
179: # define UCHAR 12
180: # define USHORT 13
181: # define UNSIGNED 14
182: # define ULONG 15
183: # define TERROR 16
184:
185: # define ASG 1+
186: # define UNARY 2+
187: # define NOASG (-1)+
188: # define NOUNARY (-2)+
189:
190: /* various flags */
191: # define NOLAB (-1)
192:
193: #ifndef FORT
194: /* type modifiers */
195:
196: # define PTR 0100
197: # define FTN 0200
198: # define ARY 0300
199:
200: /* type packing constants */
201:
202: # define TMASK 0300
203: # define TMASK1 01400
204: # define TMASK2 01700
205: # define BTMASK 077
206: # define BTSHIFT 6
207: # define TSHIFT 2
208:
209: #else FORT
210:
211: /* type modifiers */
212: # define PTR 020
213: # define FTN 040
214: # define ARY 060
215: /* type packing constants */
216: # define TMASK 060
217: # define TMASK1 0300
218: # define TMASK2 0360
219: # define BTMASK 017
220: # define BTSHIFT 4
221: # define TSHIFT 2
222:
223: #endif FORT
224:
225: /* macros */
226:
227: # define MODTYPE(x,y) x = ( (x)&(~BTMASK))|(y) /* set basic type of x to y */
228: # define BTYPE(x) ( (x)&BTMASK) /* basic type of x */
229: # define ISFLOATING(x) ((x) == FLOAT || (x) == DOUBLE)
230: # define ISUNSIGNED(x) ((x)<=ULONG&&(x)>=UCHAR)
231: # define UNSIGNABLE(x) ((x)<=LONG&&(x)>=CHAR)
232: # define ENUNSIGN(x) ((x)+(UNSIGNED-INT))
233: # define DEUNSIGN(x) ((x)+(INT-UNSIGNED))
234: # define ISPTR(x) (( (x)&TMASK)==PTR)
235: # define ISFTN(x) (( (x)&TMASK)==FTN) /* is x a function type */
236: # define ISARY(x) (( (x)&TMASK)==ARY) /* is x an array type */
237: # define INCREF(x) ((( (x)&~BTMASK)<<TSHIFT)|PTR|( (x)&BTMASK))
238: # define DECREF(x) ((( (x)>>TSHIFT)&~BTMASK)|( (x)&BTMASK))
239: # define SETOFF(x,y) if( (x)%(y) != 0 ) (x) = ( ((x)/(y) + 1) * (y))
240: /* advance x to a multiple of y */
241: # define NOFIT(x,y,z) ( ( (x)%(z) + (y) ) > (z) )
242: /* can y bits be added to x without overflowing z */
243: /* pack and unpack field descriptors (size and offset) */
244: # define PKFIELD(s,o) (( (o)<<6)| (s) )
245: # define UPKFSZ(v) ( (v) &077)
246: # define UPKFOFF(v) ( (v) >>6)
247:
248: /* operator information */
249:
250: # define TYFLG 016
251: # define ASGFLG 01
252: # define LOGFLG 020
253: # define SIMPFLG 040
254: # define COMMFLG 0100
255: # define DIVFLG 0200
256: # define FLOFLG 0400
257: # define LTYFLG 01000
258: # define CALLFLG 02000
259: # define MULFLG 04000
260: # define SHFFLG 010000
261: # define ASGOPFLG 020000
262: # define SPFLG 040000
263: # define INTRFLG 0100000
264:
265: #define optype(o) (dope[o]&TYFLG)
266: #define asgop(o) (dope[o]&ASGFLG)
267: #define logop(o) (dope[o]&LOGFLG)
268: #define callop(o) (dope[o]&CALLFLG)
269: #define commuteop(o) (dope[o]&COMMFLG)
270:
271: /* table sizes */
272:
273: # ifndef FORT
274: # define TREESZ 350 /* space for building parse tree */
275: # else
276: # define TREESZ 1000
277: # endif
278:
279: #ifndef FLEXNAMES
280: # define NCHNAM 8 /* number of characters in a name */
281: #else
282: char *hash();
283: char *savestr();
284: char *tstr();
285: extern int tstrused;
286: extern char *tstrbuf[], **curtstr;
287: #define freetstr() curtstr = tstrbuf, tstrused = 0
288: #endif
289:
290: #define malloc(nbytes) malloc_with_care(nbytes)
291: extern char *malloc();
292:
293: /* common defined variables */
294:
295: extern int nerrors; /* number of errors seen so far */
296:
297: typedef union ndu NODE;
298: typedef unsigned int TWORD;
299: # define NIL (NODE *)0
300: extern int dope[]; /* a vector containing operator information */
301: extern char *opst[]; /* a vector containing names for ops */
302:
303: # ifdef ONEPASS
304: /* in one-pass operation, define the tree nodes */
305:
306: union ndu {
307:
308: struct {
309: int op;
310: int rall;
311: TWORD type;
312: SUTYPE su;
313: #ifndef FLEXNAMES
314: char name[NCHNAM];
315: #else
316: char *name;
317: int stalign;
318: #endif
319: NODE *left;
320: NODE *right;
321: }in; /* interior node */
322:
323: struct {
324: int op;
325: int rall;
326: TWORD type;
327: SUTYPE su;
328: #ifndef FLEXNAMES
329: char name[NCHNAM];
330: #else
331: char *name;
332: int stalign;
333: #endif
334: CONSZ lval;
335: int rval;
336: }tn; /* terminal node */
337:
338: struct {
339: int op, rall;
340: TWORD type;
341: SUTYPE su;
342: int label; /* for use with branching */
343: int reversed;
344: }bn; /* branch node */
345:
346: struct {
347: int op, rall;
348: TWORD type;
349: SUTYPE su;
350: int stsize; /* sizes of structure objects */
351: int stalign; /* alignment of structure objects */
352: }stn; /* structure node */
353:
354: struct {
355: int op;
356: int cdim;
357: TWORD type;
358: int csiz;
359: }fn; /* front node */
360:
361: struct {
362: /* this structure is used when a floating point constant
363: is being computed */
364: int op;
365: int rall;
366: TWORD type;
367: SUTYPE su;
368: double dval;
369: }fpn; /* floating point node */
370:
371: };
372: # endif
373: # ifdef BUG2
374: # define BUG1
375: # endif
376: # ifdef BUG3
377: # define BUG2
378: # define BUG1
379: # endif
380: # ifdef BUG4
381: # define BUG1
382: # define BUG2
383: # define BUG3
384: # endif
385: # ifndef ONEPASS
386:
387: # ifndef EXPR
388: # define EXPR '.'
389: # endif
390: # ifndef BBEG
391: # define BBEG '['
392: # endif
393: # ifndef BEND
394: # define BEND ']'
395: # endif
396:
397: # endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.