7 int o, curframe, curbecome, maxbecome;
10 * find leaf subroutines
15 * expand BECOME pseudo
19 Bprint(&bso, "%5.2f noops\n", cputime());
27 for(p = firstp; p != P; p = p->link) {
29 /* find out how much arg space is used in this TEXT */
30 if(p->to.type == D_OREG && p->to.reg == REGSP)
31 if(p->to.offset > curframe)
32 curframe = p->to.offset;
35 /* too hard, just leave alone */
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;
47 p->mark |= LABEL|LEAF|SYNC;
49 p->link->mark |= LABEL;
55 if(p->to.type == D_REG)
56 if(p->to.reg == REGZERO)
57 p->mark |= LABEL|SYNC;
81 p->mark |= LABEL|SYNC;
134 curtext->mark &= ~LEAF;
140 curtext->mark &= ~LEAF;
181 while(q1->as == ANOP) {
185 if(!(q1->mark & LEAF))
201 p->mark |= FCMP|FLOAT;
205 /* special form of RETURN is BECOME */
206 if(p->from.type == D_CONST)
207 if(p->from.offset > curbecome)
208 curbecome = p->from.offset;
212 p->link->mark |= LABEL;
217 q->link = q1; /* q is non-nop */
226 if(curtext && curtext->from.sym) {
227 curtext->from.sym->frame = curframe;
228 curtext->from.sym->become = curbecome;
229 if(curbecome > maxbecome)
230 maxbecome = curbecome;
234 print("max become = %d\n", maxbecome);
235 xdefine("ALEFbecome", STEXT, maxbecome);
238 for(p = firstp; p != P; p = p->link) {
245 if(curtext != P && curtext->from.sym != S && curtext->to.offset >= 0) {
246 o = maxbecome - curtext->from.sym->frame;
249 /* calling a become or calling a variable */
250 if(p->to.sym == S || p->to.sym->become) {
251 curtext->to.offset += o;
254 print("%D calling %D increase %d\n",
255 &curtext->from, &p->to, o);
264 for(p = firstp; p != P; p = p->link) {
269 autosize = p->to.offset + 4;
270 if((p->mark & LEAF) && autosize <= 4)
275 p->to.offset = autosize - 4;
282 q->from.type = D_CONST;
283 q->from.offset = autosize;
290 if(!(curtext->mark & LEAF)) {
292 Bprint(&bso, "save suppressed in: %s\n",
293 curtext->from.sym->name);
294 curtext->mark |= LEAF;
297 if(curtext->mark & LEAF) {
298 if(curtext->from.sym)
299 curtext->from.sym->type = SLEAF;
306 q1->from.type = D_REG;
307 q1->from.reg = REGLINK;
308 q1->to.type = D_OREG;
323 if(p->from.type != D_REG)
325 if(p->to.type != D_REG)
337 p->from.type = D_REG;
338 p->from.reg = q1->from.reg;
351 p->from.type = D_REG;
352 p->from.reg = q1->reg;
354 p->from.reg = q1->to.reg;
359 /* CALL appropriate */
367 p->to.type = D_BRANCH;
396 p->from.type = D_REG;
397 p->from.reg = REGTMP;
400 p->to.reg = q1->to.reg;
409 p->from.type = D_CONST;
418 q1->from.type = D_CONST;
427 if(p->from.type == D_CONST)
429 if(curtext->mark & LEAF) {
441 p->from.type = D_CONST;
442 p->from.offset = autosize;
460 p->from.type = D_OREG;
464 p->to.reg = REGRET+1;
471 q->from.type = D_CONST;
472 q->from.offset = autosize;
483 q1->to.type = D_OREG;
485 q1->to.reg = REGRET+1;
493 if(curtext->mark & LEAF) {
507 p->from.type = D_CONST;
508 p->from.offset = autosize;
528 q->from.type = D_CONST;
529 q->from.offset = autosize;
537 p->from.type = D_OREG;
550 q1 = firstp; /* top of block */
551 o = 0; /* count of instructions */
552 for(p = firstp; p != P; p = p1) {
555 if(p->mark & NOSCHED){
559 for(; p != P; p = p->link){
560 if(!(p->mark & NOSCHED))
569 if(p->mark & (LABEL|SYNC)) {
575 if(p->mark & (BRANCH|SYNC)) {
597 q->from.type = D_REG;
598 q->from.reg = REGZERO;
609 Sym *s1, *s2, *s3, *s4, *s5;
612 s1 = lookup("_mul", 0);
613 s2 = lookup("_div", 0);
614 s3 = lookup("_divl", 0);
615 s4 = lookup("_mod", 0);
616 s5 = lookup("_modl", 0);
617 for(p = firstp; p != P; p = p->link)
619 if(p->from.sym == s1)
621 if(p->from.sym == s2)
623 if(p->from.sym == s3)
625 if(p->from.sym == s4)
627 if(p->from.sym == s5)
631 diag("undefined: %s", s1->name);
635 diag("undefined: %s", s2->name);
639 diag("undefined: %s", s3->name);
643 diag("undefined: %s", s4->name);
647 diag("undefined: %s", s5->name);