|
|
1.1 root 1: # include "macdefs"
2: # include "mac2defs"
3: # include "manifest"
4:
5: # ifdef ONEPASS
6:
7: /* bunch of stuff for putting the passes together... */
8: # define crslab crs2lab
9: # define where where2
10: # define xdebug x2debug
11: # define tdebug t2debug
12: # define deflab def2lab
13: # define edebug e2debug
14: # define eprint e2print
15: # define getlab get2lab
16: # define filename ftitle
17: # endif
18:
19: /* cookies, used as arguments to codgen */
20:
21: # define FOREFF 01 /* compute for effects only */
22: # define INAREG 02 /* compute into a register */
23: # define INTAREG 04 /* compute into a scratch register */
24: # define INBREG 010 /* compute into a lvalue register */
25: # define INTBREG 020 /* compute into a scratch lvalue register */
26: # define FORCC 040 /* compute for condition codes only */
27: # define INTEMP 010000 /* compute into a temporary location */
28: # define FORARG 020000 /* compute for an argument of a function */
29: # define FORREW 040000 /* search the table, looking for a rewrite rule */
30:
31: /* OP descriptors */
32: /* the ASG operator may be used on some of these */
33:
34: # define OPSIMP 010000 /* +, -, &, |, ^ */
35: # define OPCOMM 010002 /* +, &, |, ^ */
36: # define OPMUL 010004 /* *, / */
37: # define OPDIV 010006 /* /, % */
38: # define OPUNARY 010010 /* unary ops */
39: # define OPLEAF 010012 /* leaves */
40: # define OPANY 010014 /* any op... */
41: # define OPLOG 010016 /* logical ops */
42: # define OPFLOAT 010020 /* +, -, *, or / (for floats) */
43: # define OPSHFT 010022 /* <<, >> */
44: # define OPLTYPE 010024 /* leaf type nodes (e.g, NAME, ICON, etc. ) */
45:
46: /* match returns */
47:
48: # define MNOPE 010000
49: # define MDONE 010001
50:
51: /* shapes */
52:
53: # define SANY 01 /* same as FOREFF */
54: # define SAREG 02 /* same as INAREG */
55: # define STAREG 04 /* same as INTAREG */
56: # define SBREG 010 /* same as INBREG */
57: # define STBREG 020 /* same as INTBREG */
58: # define SCC 040 /* same as FORCC */
59: # define SNAME 0100
60: # define SCON 0200
61: # define SFLD 0400
62: # define SOREG 01000
63: /* indirection or wild card shapes */
64: # ifndef WCARD1
65: # define STARNM 02000
66: # endif
67: # ifndef WCARD2
68: # define STARREG 04000
69: # endif
70: # define SWADD 040000
71: # define SPECIAL 0100000
72: # define SZERO SPECIAL
73: # define SONE (SPECIAL|1)
74: # define SMONE (SPECIAL|2)
75: # define SCCON (SPECIAL|3) /* -256 <= constant < 256 */
76: # define SSCON (SPECIAL|4) /* -32768 <= constant < 32768 */
77: # define SSOREG (SPECIAL|5) /* non-indexed OREG */
78:
79: /* FORARG and INTEMP are carefully not conflicting with shapes */
80:
81: /* types */
82:
83: # define TCHAR 01
84: # define TSHORT 02
85: # define TINT 04
86: # define TLONG 010
87: # define TFLOAT 020
88: # define TDOUBLE 040
89: # define TPOINT 0100
90: # define TUCHAR 0200
91: # define TUSHORT 0400
92: # define TUNSIGNED 01000
93: # define TULONG 02000
94: # define TPTRTO 04000 /* pointer to one of the above */
95: # define TANY 010000 /* matches anything within reason */
96: # define TSTRUCT 020000 /* structure or union */
97:
98: /* reclamation cookies */
99:
100: # define RNULL 0 /* clobber result */
101: # define RLEFT 01
102: # define RRIGHT 02
103: # define RESC1 04
104: # define RESC2 010
105: # define RESC3 020
106: # define RESCC 04000
107: # define RNOP 010000 /* DANGER: can cause loops.. */
108:
109: /* needs */
110:
111: # define NAREG 01
112: # define NACOUNT 03
113: # define NAMASK 017
114: # define NASL 04 /* share left register */
115: # define NASR 010 /* share right register */
116: # define NBREG 020
117: # define NBCOUNT 060
118: # define NBMASK 0360
119: # define NBSL 0100
120: # define NBSR 0200
121: # define NTEMP 0400
122: # define NTMASK 07400
123: # define REWRITE 010000
124: # define EITHER 040000 /* "either" modifier for needs */
125:
126:
127: # define MUSTDO 010000 /* force register requirements */
128: # define NOPREF 020000 /* no preference for register assignment */
129:
130:
131: /* register allocation */
132:
133: extern int rstatus[];
134: extern int busy[];
135:
136: extern struct respref { int cform; int mform; } respref[];
137:
138: # define isbreg(r) (rstatus[r]&SBREG)
139: # define istreg(r) (rstatus[r]&(STBREG|STAREG))
140: # define istnode(p) (p->in.op==REG && istreg(p->tn.rval))
141:
142: # define TBUSY 01000
143: # define REGLOOP(i) for(i=0;i<REGSZ;++i)
144:
145: # define SETSTO(x,y) (stotree=(x),stocook=(y))
146: extern int stocook;
147: # define DELAYS 20
148: extern NODE *deltrees[DELAYS];
149: extern int deli; /* mmmmm */
150:
151: extern NODE *stotree;
152: extern int callflag;
153:
154: extern int fregs;
155:
156: # ifndef ONEPASS
157: union ndu {
158:
159: struct {
160: int op;
161: int rall;
162: TWORD type;
163: int su;
164: int stalign; /* alignment of structure objects */
165: #ifndef FLEXNAMES
166: char name[NCHNAM];
167: #else
168: char *name;
169: #endif
170: NODE *left;
171: NODE *right;
172: }in; /* interior node */
173:
174: struct {
175: int op;
176: int rall;
177: TWORD type;
178: int su;
179: int stalign; /* alignment of structure objects */
180: #ifndef FLEXNAMES
181: char name[NCHNAM];
182: #else
183: char *name;
184: #endif
185: CONSZ lval;
186: int rval;
187: }tn; /* terminal node */
188:
189: struct {
190: int op, rall;
191: TWORD type;
192: int su;
193: int stalign; /* alignment of structure objects */
194: int label; /* for use with branching */
195: }bn; /* branch node */
196:
197: struct {
198: int op, rall;
199: TWORD type;
200: int su;
201: int stalign; /* alignment of structure objects */
202: int stsize; /* sizes of structure objects */
203: }stn; /* structure node */
204:
205: };
206: #endif
207:
208: extern NODE node[];
209:
210: extern struct optab {
211: int op;
212: int visit;
213: int lshape;
214: int ltype;
215: int rshape;
216: int rtype;
217: int needs;
218: int rewrite;
219: char * cstring;
220: }
221: table[];
222:
223: extern NODE resc[];
224:
225: extern OFFSZ tmpoff;
226: extern OFFSZ maxoff;
227: extern OFFSZ baseoff;
228: extern OFFSZ maxtemp;
229: extern int maxtreg;
230: extern int ftnno;
231: extern int rtyflg;
232:
233: extern int nrecur; /* flag to keep track of recursions */
234:
235: # define NRECUR (10*TREESZ)
236:
237: extern NODE
238: *talloc(),
239: *eread(),
240: *tcopy(),
241: *getlr();
242:
243: extern CONSZ rdin();
244:
245: extern int eprint();
246:
247: extern char *rnames[];
248:
249: extern int lineno;
250: extern char filename[];
251: extern int fldshf, fldsz;
252: extern int lflag, xdebug, udebug, edebug, odebug, rdebug, radebug, tdebug, sdebug;
253:
254: #ifndef callchk
255: #define callchk(x) allchk()
256: #endif
257:
258: #ifndef PUTCHAR
259: # define PUTCHAR(x) putchar(x)
260: #endif
261:
262: /* macros for doing double indexing */
263: # define R2PACK(x,y,z) (0200*((x)+1)+y+040000*z)
264: # define R2UPK1(x) ((((x)>>7)-1)&0177)
265: # define R2UPK2(x) ((x)&0177)
266: # define R2UPK3(x) (x>>14)
267: # define R2TEST(x) ((x)>=0200)
268:
269: # ifdef MULTILEVEL
270:
271: union mltemplate{
272: struct ml_head{
273: int tag; /* identifies class of tree */
274: int subtag; /* subclass of tree */
275: union mltemplate * nexthead; /* linked by mlinit() */
276: } mlhead;
277: struct ml_node{
278: int op; /* either an operator or op description */
279: int nshape; /* shape of node */
280: /* both op and nshape must match the node.
281: * where the work is to be done entirely by
282: * op, nshape can be SANY, visa versa, op can
283: * be OPANY.
284: */
285: int ntype; /* type descriptor from mfile2 */
286: } mlnode;
287: };
288:
289: # endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.