7 int o, curframe, curbecome, maxbecome;
10 * find leaf subroutines
15 * expand BECOME pseudo
19 Bprint(&bso, "%5.2f noops\n", cputime());
28 for(p = firstp; p != P; p = p->link) {
30 /* find out how much arg space is used in this TEXT */
31 if(p->to.type == D_OREG && p->to.reg == REGSP)
32 if(p->to.offset > curframe)
33 curframe = p->to.offset;
37 if(curtext && curtext->from.sym) {
38 curtext->from.sym->frame = curframe;
39 curtext->from.sym->become = curbecome;
40 if(curbecome > maxbecome)
41 maxbecome = curbecome;
46 p->mark |= LABEL|LEAF|SYNC;
48 p->link->mark |= LABEL;
52 /* too hard, just leave alone */
54 if(p->to.type == D_FCREG ||
55 p->to.type == D_MREG) {
56 p->mark |= LABEL|SYNC;
59 if(p->from.type == D_FCREG ||
60 p->from.type == D_MREG) {
61 p->mark |= LABEL|SYNC;
70 /* too hard, just leave alone */
78 p->mark |= LABEL|SYNC;
82 if(p->to.type == D_REG && p->to.reg == REGZERO)
83 p->mark |= LABEL|SYNC;
87 /* special form of RET is BECOME */
88 if(p->from.type == D_CONST)
89 if(p->from.offset > curbecome)
90 curbecome = p->from.offset;
93 p->link->mark |= LABEL;
98 q->link = q1; /* q is non-nop */
103 p->mark |= LABEL|SYNC;
110 curtext->mark &= ~LEAF;
126 while(q1->as == ANOP) {
130 if(!(q1->mark & LEAF))
142 if(curtext && curtext->from.sym) {
143 curtext->from.sym->frame = curframe;
144 curtext->from.sym->become = curbecome;
145 if(curbecome > maxbecome)
146 maxbecome = curbecome;
150 print("max become = %d\n", maxbecome);
151 xdefine("ALEFbecome", STEXT, maxbecome);
154 for(p = firstp; p != P; p = p->link) {
160 if(curtext != P && curtext->from.sym != S && curtext->to.offset >= 0) {
161 o = maxbecome - curtext->from.sym->frame;
164 /* calling a become or calling a variable */
165 if(p->to.sym == S || p->to.sym->become) {
166 curtext->to.offset += o;
169 print("%D calling %D increase %d\n",
170 &curtext->from, &p->to, o);
178 for(p = firstp; p != P; p = p->link) {
183 autosize = p->to.offset + 4;
185 if(curtext->mark & LEAF) {
195 q->from.type = D_CONST;
196 q->from.offset = -autosize;
203 if(!(curtext->mark & LEAF)) {
205 Bprint(&bso, "save suppressed in: %s\n",
206 curtext->from.sym->name);
208 curtext->mark |= LEAF;
211 if(curtext->mark & LEAF) {
212 if(curtext->from.sym)
213 curtext->from.sym->type = SLEAF;
220 q1->from.type = D_REG;
221 q1->from.reg = REGLINK;
222 q1->to.type = D_OREG;
232 if(p->from.type == D_CONST)
234 if(curtext->mark & LEAF) {
246 p->from.type = D_CONST;
247 p->from.offset = autosize;
264 p->from.type = D_OREG;
275 q->from.type = D_CONST;
276 q->from.offset = autosize;
287 q1->to.type = D_OREG;
297 if(curtext->mark & LEAF) {
311 p->from.type = D_CONST;
312 p->from.offset = autosize;
332 q->from.type = D_CONST;
333 q->from.offset = autosize;
341 p->from.type = D_OREG;
354 q1 = firstp; /* top of block */
355 o = 0; /* count of instructions */
356 for(p = firstp; p != P; p = p1) {
359 if(p->mark & NOSCHED){
363 for(; p != P; p = p->link){
364 if(!(p->mark & NOSCHED))
373 if(p->mark & (LABEL|SYNC)) {
379 if(p->mark & (BRANCH|SYNC)) {
401 q->from.type = D_REG;
402 q->from.reg = REGZERO;