]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/vc/gc.h
stats: show amount of reclaimable pages (add -r flag)
[plan9front.git] / sys / src / cmd / vc / gc.h
1 #include        "../cc/cc.h"
2 #include        "../vc/v.out.h"
3
4 /*
5  * vc/mips
6  * Mips 3000
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  Multab  Multab;
23 typedef struct  Hintab  Hintab;
24 typedef struct  Var     Var;
25 typedef struct  Reg     Reg;
26 typedef struct  Rgn     Rgn;
27
28 struct  Adr
29 {
30         long    offset;
31         double  dval;
32         char    sval[NSNAME];
33         Ieee    ieee;
34
35         Sym*    sym;
36         char    type;
37         char    reg;
38         char    name;
39         char    etype;
40 };
41 #define A       ((Adr*)0)
42
43 #define INDEXED 9
44 struct  Prog
45 {
46         Adr     from;
47         Adr     to;
48         Prog*   link;
49         long    lineno;
50         char    as;
51         char    reg;
52 };
53 #define P       ((Prog*)0)
54
55 struct  Case
56 {
57         Case*   link;
58         vlong   val;
59         long    label;
60         char    def;
61         char isv;
62 };
63 #define C       ((Case*)0)
64
65 struct  C1
66 {
67         vlong   val;
68         long    label;
69 };
70
71 struct  Multab
72 {
73         long    val;
74         char    code[20];
75 };
76
77 struct  Hintab
78 {
79         ushort  val;
80         char    hint[10];
81 };
82
83 struct  Var
84 {
85         long    offset;
86         Sym*    sym;
87         char    name;
88         char    etype;
89 };
90
91 struct  Reg
92 {
93         long    pc;
94         long    rpo;            /* reverse post ordering */
95
96         Bits    set;
97         Bits    use1;
98         Bits    use2;
99
100         Bits    refbehind;
101         Bits    refahead;
102         Bits    calbehind;
103         Bits    calahead;
104         Bits    regdiff;
105         Bits    act;
106
107         long    regu;
108         long    loop;           /* could be shorter */
109
110         Reg*    log5;
111         long    active;
112
113         Reg*    p1;
114         Reg*    p2;
115         Reg*    p2link;
116         Reg*    s1;
117         Reg*    s2;
118         Reg*    link;
119         Prog*   prog;
120 };
121 #define R       ((Reg*)0)
122
123 #define NRGN    600
124 struct  Rgn
125 {
126         Reg*    enter;
127         short   cost;
128         short   varno;
129         short   regno;
130 };
131
132 EXTERN  long    breakpc;
133 EXTERN  long    nbreak;
134 EXTERN  Case*   cases;
135 EXTERN  Node    constnode;
136 EXTERN  Node    fconstnode;
137 EXTERN  long    continpc;
138 EXTERN  long    curarg;
139 EXTERN  long    cursafe;
140 EXTERN  Prog*   firstp;
141 EXTERN  Prog*   lastp;
142 EXTERN  long    maxargsafe;
143 EXTERN  int     mnstring;
144 EXTERN  Multab  multab[20];
145 EXTERN  int     hintabsize;
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  char    string[NSNAME];
155 EXTERN  Sym*    symrathole;
156 EXTERN  Node    znode;
157 EXTERN  Prog    zprog;
158 EXTERN  int     reg[NREG+NREG];
159 EXTERN  long    exregoffset;
160 EXTERN  long    exfregoffset;
161
162 #define BLOAD(r)        band(bnot(r->refbehind), r->refahead)
163 #define BSTORE(r)       band(bnot(r->calbehind), r->calahead)
164 #define LOAD(r)         (~r->refbehind.b[z] & r->refahead.b[z])
165 #define STORE(r)        (~r->calbehind.b[z] & r->calahead.b[z])
166
167 #define bset(a,n)       ((a).b[(n)/32]&(1L<<(n)%32))
168
169 #define CLOAD   4
170 #define CREF    5
171 #define CINF    1000
172 #define LOOP    3
173
174 EXTERN  Rgn     region[NRGN];
175 EXTERN  Rgn*    rgp;
176 EXTERN  int     nregion;
177 EXTERN  int     nvar;
178
179 EXTERN  Bits    externs;
180 EXTERN  Bits    params;
181 EXTERN  Bits    consts;
182 EXTERN  Bits    addrs;
183
184 EXTERN  long    regbits;
185 EXTERN  long    exregbits;
186
187 EXTERN  int     change;
188 EXTERN  int     suppress;
189
190 EXTERN  Reg*    firstr;
191 EXTERN  Reg*    lastr;
192 EXTERN  Reg     zreg;
193 EXTERN  Reg*    freer;
194 EXTERN  Var     var[NVAR];
195 EXTERN  long*   idom;
196 EXTERN  Reg**   rpo2r;
197 EXTERN  long    maxnr;
198
199 extern  char*   anames[];
200 extern  Hintab  hintab[];
201
202 /*
203  * sgen.c
204  */
205 void    codgen(Node*, Node*);
206 void    gen(Node*);
207 void    noretval(int);
208 void    xcom(Node*);
209 int     bcomplex(Node*, Node*);
210 void    usedset(Node*, int);
211
212 /*
213  * cgen.c
214  */
215 void    cgen(Node*, Node*);
216 void    reglcgen(Node*, Node*, Node*);
217 void    lcgen(Node*, Node*);
218 void    bcgen(Node*, int);
219 void    boolgen(Node*, int, Node*);
220 void    sugen(Node*, Node*, long);
221 void    layout(Node*, Node*, int, int, Node*);
222
223 /*
224  * txt.c
225  */
226 void    ginit(void);
227 void    gclean(void);
228 void    nextpc(void);
229 void    gargs(Node*, Node*, Node*);
230 void    garg1(Node*, Node*, Node*, int, Node**);
231 Node*   nodconst(long);
232 Node*   nod32const(vlong);
233 Node*   nodfconst(double);
234 void    nodreg(Node*, Node*, int);
235 void    regret(Node*, Node*);
236 void    regalloc(Node*, Node*, Node*);
237 void    regfree(Node*);
238 void    regialloc(Node*, Node*, Node*);
239 void    regsalloc(Node*, Node*);
240 void    regaalloc1(Node*, Node*);
241 void    regaalloc(Node*, Node*);
242 void    regind(Node*, Node*);
243 void    gprep(Node*, Node*);
244 void    raddr(Node*, Prog*);
245 void    naddr(Node*, Adr*);
246 void    gmove(Node*, Node*);
247 void    gins(int a, Node*, Node*);
248 void    gopcode(int, Node*, Node*, Node*);
249 int     samaddr(Node*, Node*);
250 void    gbranch(int);
251 void    patch(Prog*, long);
252 int     sconst(Node*);
253 int     sval(long);
254 void    gpseudo(int, Sym*, Node*);
255
256 /*
257  * swt.c
258  */
259 int     swcmp(const void*, const void*);
260 void    doswit(Node*);
261 void    swit1(C1*, int, long, Node*);
262 void    swit2(C1*, int, long, Node*, Node*);
263 void    casf(void);
264 void    bitload(Node*, Node*, Node*, Node*, Node*);
265 void    bitstore(Node*, Node*, Node*, Node*, Node*);
266 long    outstring(char*, long);
267 int     mulcon(Node*, Node*);
268 Multab* mulcon0(long);
269 void    nullwarn(Node*, Node*);
270 void    sextern(Sym*, Node*, long, long);
271 void    gextern(Sym*, Node*, long, long);
272 void    outcode(void);
273 void    ieeedtod(Ieee*, double);
274
275 /*
276  * list
277  */
278 void    listinit(void);
279 int     Pconv(Fmt*);
280 int     Aconv(Fmt*);
281 int     Dconv(Fmt*);
282 int     Sconv(Fmt*);
283 int     Nconv(Fmt*);
284 int     Bconv(Fmt*);
285
286 /*
287  * reg.c
288  */
289 Reg*    rega(void);
290 int     rcmp(const void*, const void*);
291 void    regopt(Prog*);
292 void    addmove(Reg*, int, int, int);
293 Bits    mkvar(Adr*, int);
294 void    prop(Reg*, Bits, Bits);
295 void    loopit(Reg*, long);
296 void    synch(Reg*, Bits);
297 ulong   allreg(ulong, Rgn*);
298 void    paint1(Reg*, int);
299 ulong   paint2(Reg*, int);
300 void    paint3(Reg*, int, long, int);
301 void    addreg(Adr*, int);
302
303 /*
304  * peep.c
305  */
306 void    peep(void);
307 void    excise(Reg*);
308 Reg*    uniqp(Reg*);
309 Reg*    uniqs(Reg*);
310 int     regtyp(Adr*);
311 int     regzer(Adr*);
312 int     anyvar(Adr*);
313 int     subprop(Reg*);
314 int     copyprop(Reg*);
315 int     copy1(Adr*, Adr*, Reg*, int);
316 int     copyu(Prog*, Adr*, Adr*);
317
318 int     copyas(Adr*, Adr*);
319 int     copyau(Adr*, Adr*);
320 int     copyau1(Prog*, Adr*);
321 int     copysub(Adr*, Adr*, Adr*, int);
322 int     copysub1(Prog*, Adr*, Adr*, int);
323
324 long    RtoB(int);
325 long    FtoB(int);
326 int     BtoR(long);
327 int     BtoF(long);
328
329 #pragma varargck        type    "A"     int
330 #pragma varargck        type    "B"     Bits
331 #pragma varargck        type    "D"     Adr*
332 #pragma varargck        type    "N"     Adr*
333 #pragma varargck        type    "P"     Prog*
334 #pragma varargck        type    "S"     char*