]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/8c/gc.h
etheriwl: don't break controller on command flush timeout
[plan9front.git] / sys / src / cmd / 8c / gc.h
1 #include        "../cc/cc.h"
2 #include        "../8c/8.out.h"
3
4 /*
5  * 8c/386
6  * Intel 386
7  */
8 #define SZ_CHAR         1
9 #define SZ_SHORT        2
10 #define SZ_INT          4
11 #define SZ_LONG         4
12 #define SZ_IND          4
13 #define SZ_FLOAT        4
14 #define SZ_VLONG        8
15 #define SZ_DOUBLE       8
16 #define FNX             100
17
18 typedef struct  Adr     Adr;
19 typedef struct  Prog    Prog;
20 typedef struct  Case    Case;
21 typedef struct  C1      C1;
22 typedef struct  Var     Var;
23 typedef struct  Reg     Reg;
24 typedef struct  Rgn     Rgn;
25 typedef struct  Renv    Renv;
26
27 EXTERN  struct
28 {
29         Node*   regtree;
30         Node*   basetree;
31         short   scale;
32         short   reg;
33         short   ptr;
34 } idx;
35
36 struct  Adr
37 {
38         long    offset;
39         double  dval;
40         char    sval[NSNAME];
41
42         Sym*    sym;
43         uchar   type;
44         uchar   index;
45         uchar   etype;
46         uchar   scale;  /* doubles as width in DATA op */
47 };
48 #define A       ((Adr*)0)
49
50 #define INDEXED 9
51 struct  Prog
52 {
53         Adr     from;
54         Adr     to;
55         Prog*   link;
56         long    lineno;
57         short   as;
58 };
59 #define P       ((Prog*)0)
60
61 struct  Case
62 {
63         Case*   link;
64         vlong   val;
65         long    label;
66         char    def;
67         char isv;
68 };
69 #define C       ((Case*)0)
70
71 struct  C1
72 {
73         vlong   val;
74         long    label;
75 };
76
77 struct  Var
78 {
79         long    offset;
80         Sym*    sym;
81         char    name;
82         char    etype;
83 };
84
85 struct  Reg
86 {
87         long    pc;
88         long    rpo;            /* reverse post ordering */
89
90         Bits    set;
91         Bits    use1;
92         Bits    use2;
93
94         Bits    refbehind;
95         Bits    refahead;
96         Bits    calbehind;
97         Bits    calahead;
98         Bits    regdiff;
99         Bits    act;
100
101         long    regu;
102         long    loop;           /* could be shorter */
103
104         Reg*    log5;
105         long    active;
106
107         Reg*    p1;
108         Reg*    p2;
109         Reg*    p2link;
110         Reg*    s1;
111         Reg*    s2;
112         Reg*    link;
113         Prog*   prog;
114 };
115 #define R       ((Reg*)0)
116
117 struct  Renv
118 {
119         int     safe;
120         Node    base;
121         Node*   saved;
122         Node*   scope;
123 };
124
125 #define NRGN    600
126 struct  Rgn
127 {
128         Reg*    enter;
129         short   cost;
130         short   varno;
131         short   regno;
132 };
133
134 EXTERN  long    breakpc;
135 EXTERN  long    nbreak;
136 EXTERN  Case*   cases;
137 EXTERN  Node    constnode;
138 EXTERN  Node    fconstnode;
139 EXTERN  long    continpc;
140 EXTERN  long    curarg;
141 EXTERN  long    cursafe;
142 EXTERN  Prog*   firstp;
143 EXTERN  Prog*   lastp;
144 EXTERN  long    maxargsafe;
145 EXTERN  int     mnstring;
146 EXTERN  Node*   nodrat;
147 EXTERN  Node*   nodret;
148 EXTERN  Node*   nodsafe;
149 EXTERN  long    nrathole;
150 EXTERN  long    nstring;
151 EXTERN  Prog*   p;
152 EXTERN  long    pc;
153 EXTERN  Node    regnode;
154 EXTERN  Node    fregnode0;
155 EXTERN  Node    fregnode1;
156 EXTERN  char    string[NSNAME];
157 EXTERN  Sym*    symrathole;
158 EXTERN  Node    znode;
159 EXTERN  Prog    zprog;
160 EXTERN  int     reg[D_NONE];
161 EXTERN  long    exregoffset;
162 EXTERN  long    exfregoffset;
163
164 #define BLOAD(r)        band(bnot(r->refbehind), r->refahead)
165 #define BSTORE(r)       band(bnot(r->calbehind), r->calahead)
166 #define LOAD(r)         (~r->refbehind.b[z] & r->refahead.b[z])
167 #define STORE(r)        (~r->calbehind.b[z] & r->calahead.b[z])
168
169 #define bset(a,n)       ((a).b[(n)/32]&(1L<<(n)%32))
170
171 #define CLOAD   5
172 #define CREF    5
173 #define CINF    1000
174 #define LOOP    3
175
176 EXTERN  Rgn     region[NRGN];
177 EXTERN  Rgn*    rgp;
178 EXTERN  int     nregion;
179 EXTERN  int     nvar;
180
181 EXTERN  Bits    externs;
182 EXTERN  Bits    params;
183 EXTERN  Bits    consts;
184 EXTERN  Bits    addrs;
185
186 EXTERN  long    regbits;
187 EXTERN  long    exregbits;
188
189 EXTERN  int     change;
190 EXTERN  int     suppress;
191
192 EXTERN  Reg*    firstr;
193 EXTERN  Reg*    lastr;
194 EXTERN  Reg     zreg;
195 EXTERN  Reg*    freer;
196 EXTERN  Var     var[NVAR];
197 EXTERN  long*   idom;
198 EXTERN  Reg**   rpo2r;
199 EXTERN  long    maxnr;
200
201 extern  char*   anames[];
202
203 /*
204  * sgen.c
205  */
206 void    codgen(Node*, Node*);
207 void    gen(Node*);
208 void    noretval(int);
209 void    usedset(Node*, int);
210 void    xcom(Node*);
211 void    indx(Node*);
212 int     bcomplex(Node*, Node*);
213
214 /*
215  * cgen.c
216  */
217 void    zeroregm(Node*);
218 void    cgen(Node*, Node*);
219 void    reglcgen(Node*, Node*, Node*);
220 void    lcgen(Node*, Node*);
221 void    bcgen(Node*, int);
222 void    boolgen(Node*, int, Node*);
223 void    sugen(Node*, Node*, long);
224 int     needreg(Node*, int);
225
226 /*
227  * cgen64.c
228  */
229 int     vaddr(Node*, int);
230 void    loadpair(Node*, Node*);
231 int     cgen64(Node*, Node*);
232 void    testv(Node*, int);
233
234 /*
235  * txt.c
236  */
237 void    ginit(void);
238 void    gclean(void);
239 void    nextpc(void);
240 void    gargs(Node*, Node*, Node*);
241 void    garg1(Node*, Node*, Node*, int, Node**);
242 Node*   nodconst(long);
243 int     nareg(int);
244 Node*   nodfconst(double);
245 int     nodreg(Node*, Node*, int);
246 int     isreg(Node*, int);
247 void    regret(Node*, Node*);
248 void    regalloc(Node*, Node*, Node*);
249 void    regfree(Node*);
250 void    regialloc(Node*, Node*, Node*);
251 void    regsalloc(Node*, Node*);
252 void    regaalloc1(Node*, Node*);
253 void    regaalloc(Node*, Node*);
254 void    regind(Node*, Node*);
255 void    gprep(Node*, Node*);
256 void    naddr(Node*, Adr*);
257 void    gmove(Node*, Node*);
258 void    gins(int a, Node*, Node*);
259 void    fgopcode(int, Node*, Node*, int, int);
260 void    gopcode(int, Type*, Node*, Node*);
261 int     samaddr(Node*, Node*);
262 void    gbranch(int);
263 void    patch(Prog*, long);
264 int     sconst(Node*);
265 void    gpseudo(int, Sym*, Node*);
266
267 /*
268  * swt.c
269  */
270 int     swcmp(const void*, const void*);
271 void    doswit(Node*);
272 void    swit1(C1*, int, long, Node*);
273 void    casf(void);
274 void    bitload(Node*, Node*, Node*, Node*, Node*);
275 void    bitstore(Node*, Node*, Node*, Node*, Node*);
276 long    outstring(char*, long);
277 void    nullwarn(Node*, Node*);
278 void    sextern(Sym*, Node*, long, long);
279 void    gextern(Sym*, Node*, long, long);
280 void    outcode(void);
281 void    ieeedtod(Ieee*, double);
282
283 /*
284  * list
285  */
286 void    listinit(void);
287 int     Pconv(Fmt*);
288 int     Aconv(Fmt*);
289 int     Dconv(Fmt*);
290 int     Sconv(Fmt*);
291 int     Rconv(Fmt*);
292 int     Xconv(Fmt*);
293 int     Bconv(Fmt*);
294
295 /*
296  * reg.c
297  */
298 Reg*    rega(void);
299 int     rcmp(const void*, const void*);
300 void    regopt(Prog*);
301 void    addmove(Reg*, int, int, int);
302 Bits    mkvar(Reg*, Adr*, int);
303 void    prop(Reg*, Bits, Bits);
304 void    loopit(Reg*, long);
305 void    synch(Reg*, Bits);
306 ulong   allreg(ulong, Rgn*);
307 void    paint1(Reg*, int);
308 ulong   paint2(Reg*, int);
309 void    paint3(Reg*, int, long, int);
310 void    addreg(Adr*, int);
311
312 /*
313  * peep.c
314  */
315 void    peep(void);
316 void    excise(Reg*);
317 Reg*    uniqp(Reg*);
318 Reg*    uniqs(Reg*);
319 int     regtyp(Adr*);
320 int     anyvar(Adr*);
321 int     subprop(Reg*);
322 int     copyprop(Reg*);
323 int     copy1(Adr*, Adr*, Reg*, int);
324 int     copyu(Prog*, Adr*, Adr*);
325
326 int     copyas(Adr*, Adr*);
327 int     copyau(Adr*, Adr*);
328 int     copysub(Adr*, Adr*, Adr*, int);
329 int     copysub1(Prog*, Adr*, Adr*, int);
330
331 long    RtoB(int);
332 long    FtoB(int);
333 int     BtoR(long);
334 int     BtoF(long);
335
336 #define D_HI    D_NONE
337 #define D_LO    D_NONE
338
339 /*
340  * com64
341  */
342 int     cond(int);
343 int     com64(Node*);
344 void    com64init(void);
345 void    bool64(Node*);
346 long    lo64v(Node*);
347 long    hi64v(Node*);
348 Node*   lo64(Node*);
349 Node*   hi64(Node*);
350
351 /*
352  * div/mul
353  */
354 void    sdivgen(Node*, Node*, Node*, Node*);
355 void    udivgen(Node*, Node*, Node*, Node*);
356 void    sdiv2(long, int, Node*, Node*);
357 void    smod2(long, int, Node*, Node*);
358 void    mulgen(Type*, Node*, Node*);
359 void    genmuladd(Node*, Node*, int, Node*);
360 void    shiftit(Type*, Node*, Node*);
361
362 #pragma varargck        type    "A"     int
363 #pragma varargck        type    "B"     Bits
364 #pragma varargck        type    "D"     Adr*
365 #pragma varargck        type    "P"     Prog*
366 #pragma varargck        type    "R"     int
367 #pragma varargck        type    "S"     char*
368
369 /* wrecklessly steal a field */
370
371 #define rplink  label