Commit | Line | Data |
---|---|---|
1ce5c0bc SJ |
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 | # define STARNM 02000 | |
64 | # define STARREG 04000 | |
65 | # define SWADD 040000 | |
66 | # define SPECIAL 0100000 | |
67 | # define SZERO SPECIAL | |
68 | # define SONE (SPECIAL|1) | |
69 | # define SMONE (SPECIAL|2) | |
70 | ||
71 | /* FORARG and INTEMP are carefully not conflicting with shapes */ | |
72 | ||
73 | /* types */ | |
74 | ||
75 | # define TCHAR 01 | |
76 | # define TSHORT 02 | |
77 | # define TINT 04 | |
78 | # define TLONG 010 | |
79 | # define TFLOAT 020 | |
80 | # define TDOUBLE 040 | |
81 | # define TPOINT 0100 | |
82 | # define TUCHAR 0200 | |
83 | # define TUSHORT 0400 | |
84 | # define TUNSIGNED 01000 | |
85 | # define TULONG 02000 | |
86 | # define TPTRTO 04000 /* pointer to one of the above */ | |
87 | # define TANY 010000 /* matches anything within reason */ | |
88 | # define TSTRUCT 020000 /* structure or union */ | |
89 | ||
90 | /* reclamation cookies */ | |
91 | ||
92 | # define RNULL 0 /* clobber result */ | |
93 | # define RLEFT 01 | |
94 | # define RRIGHT 02 | |
95 | # define RESC1 04 | |
96 | # define RESC2 010 | |
97 | # define RESC3 020 | |
98 | # define RESCC 04000 | |
99 | # define RNOP 010000 /* DANGER: can cause loops.. */ | |
100 | ||
101 | /* needs */ | |
102 | ||
103 | # define NAREG 01 | |
104 | # define NACOUNT 03 | |
105 | # define NAMASK 017 | |
106 | # define NASL 04 /* share left register */ | |
107 | # define NASR 010 /* share right register */ | |
108 | # define NBREG 020 | |
109 | # define NBCOUNT 060 | |
110 | # define NBMASK 0360 | |
111 | # define NBSL 0100 | |
112 | # define NBSR 0200 | |
113 | # define NTEMP 0400 | |
114 | # define NTMASK 07400 | |
115 | # define REWRITE 010000 | |
116 | ||
117 | ||
118 | # define MUSTDO 010000 /* force register requirements */ | |
119 | # define NOPREF 020000 /* no preference for register assignment */ | |
120 | ||
121 | ||
122 | /* register allocation */ | |
123 | ||
124 | extern int rstatus[]; | |
125 | extern int busy[]; | |
126 | ||
127 | extern struct respref { int cform; int mform; } respref[]; | |
128 | ||
129 | # define isbreg(r) (rstatus[r]&SBREG) | |
130 | # define istreg(r) (rstatus[r]&(STBREG|STAREG)) | |
131 | # define istnode(p) (p->op==REG && istreg(p->rval)) | |
132 | ||
133 | # define TBUSY 01000 | |
134 | # define REGLOOP(i) for(i=0;i<REGSZ;++i) | |
135 | ||
136 | # define SETSTO(x,y) (stotree=(x),stocook=(y)) | |
137 | extern int stocook; | |
138 | # define DELAYS 20 | |
139 | extern NODE *deltrees[DELAYS]; | |
140 | extern int deli; /* mmmmm */ | |
141 | ||
142 | extern NODE *stotree; | |
143 | extern int callflag; | |
144 | ||
145 | extern int fregs; | |
146 | ||
147 | # ifndef ONEPASS | |
148 | union ndu { | |
149 | ||
150 | struct { | |
151 | int op; | |
152 | int rall; | |
153 | TWORD type; | |
154 | int su; | |
155 | char name[NCHNAM]; | |
156 | NODE *left; | |
157 | NODE *right; | |
158 | }; | |
159 | ||
160 | struct { | |
161 | int op; | |
162 | int rall; | |
163 | TWORD type; | |
164 | int su; | |
165 | char name[NCHNAM]; | |
166 | CONSZ lval; | |
167 | int rval; | |
168 | }; | |
169 | ||
170 | struct { | |
171 | int op, rall; | |
172 | TWORD type; | |
173 | int su; | |
174 | int label; /* for use with branching */ | |
175 | }; | |
176 | ||
177 | struct { | |
178 | int op, rall; | |
179 | TWORD type; | |
180 | int su; | |
181 | int stsize; /* sizes of structure objects */ | |
182 | int stalign; /* alignment of structure objects */ | |
183 | }; | |
184 | ||
185 | }; | |
186 | #endif | |
187 | ||
188 | extern NODE node[]; | |
189 | ||
190 | extern struct optab { | |
191 | int op; | |
192 | int visit; | |
193 | int lshape; | |
194 | int ltype; | |
195 | int rshape; | |
196 | int rtype; | |
197 | int needs; | |
198 | int rewrite; | |
199 | char * cstring; | |
200 | } | |
201 | table[]; | |
202 | ||
203 | extern NODE resc[]; | |
204 | ||
205 | extern OFFSZ tmpoff; | |
206 | extern OFFSZ maxoff; | |
207 | extern OFFSZ baseoff; | |
208 | extern OFFSZ maxtemp; | |
209 | extern int maxtreg; | |
210 | extern int ftnno; | |
211 | extern int rtyflg; | |
212 | ||
213 | extern int nrecur; /* flag to keep track of recursions */ | |
214 | ||
215 | # define NRECUR (10*TREESZ) | |
216 | ||
217 | extern NODE | |
218 | *talloc(), | |
219 | *eread(), | |
220 | *tcopy(), | |
221 | *getlr(); | |
222 | ||
223 | extern CONSZ rdin(); | |
224 | ||
225 | extern int eprint(); | |
226 | ||
227 | extern char *rnames[]; | |
228 | ||
229 | extern int lineno; | |
230 | extern char filename[]; | |
231 | extern int fldshf, fldsz; | |
232 | extern int lflag, xdebug, udebug, edebug, odebug, rdebug, radebug, tdebug, sdebug; | |
233 | ||
234 | #ifndef callchk | |
235 | #define callchk(x) allchk() | |
236 | #endif | |
237 | ||
238 | #ifndef PUTCHAR | |
239 | # define PUTCHAR(x) putchar(x) | |
240 | #endif | |
241 | ||
242 | /* macros for doing double indexing */ | |
243 | # define R2PACK(x,y) (0200*((x)+1)+y) | |
244 | # define R2UPK1(x) (((x)>>7)-1) | |
245 | # define R2UPK2(x) ((x)&0177) | |
246 | # define R2TEST(x) ((x)>=0200) |