12 int o, curframe, curbecome, maxbecome;
15 * find leaf subroutines
20 * expand BECOME pseudo
24 Bprint(&bso, "%5.2f noops\n", cputime());
33 for(p = firstp; p != P; p = p->link) {
35 /* find out how much arg space is used in this TEXT */
36 if(p->to.type == D_OREG && p->to.reg == REGSP)
37 if(p->to.offset > curframe)
38 curframe = p->to.offset;
42 if(curtext && curtext->from.sym) {
43 curtext->from.sym->frame = curframe;
44 curtext->from.sym->become = curbecome;
45 if(curbecome > maxbecome)
46 maxbecome = curbecome;
56 /* special form of RET is BECOME */
57 if(p->from.type == D_CONST)
58 if(p->from.offset > curbecome)
59 curbecome = p->from.offset;
70 curtext->mark &= ~LEAF;
75 q->link = q1; /* q is non-nop */
81 curtext->mark &= ~LEAF;
105 while(q1->as == ANOP) {
115 if(curtext && curtext->from.sym) {
116 curtext->from.sym->frame = curframe;
117 curtext->from.sym->become = curbecome;
118 if(curbecome > maxbecome)
119 maxbecome = curbecome;
123 print("max become = %d\n", maxbecome);
124 xdefine("ALEFbecome", STEXT, maxbecome);
127 for(p = firstp; p != P; p = p->link) {
133 if(curtext != P && curtext->from.sym != S && curtext->to.offset >= 0) {
134 o = maxbecome - curtext->from.sym->frame;
137 /* calling a become or calling a variable */
138 if(p->to.sym == S || p->to.sym->become) {
139 curtext->to.offset += o;
142 print("%D calling %D increase %d\n",
143 &curtext->from, &p->to, o);
151 for(p = firstp; p != P; p = p->link) {
156 autosize = p->to.offset + 4;
158 if(curtext->mark & LEAF) {
163 if(!autosize && !(curtext->mark & LEAF)) {
165 Bprint(&bso, "save suppressed in: %s\n",
166 curtext->from.sym->name);
168 curtext->mark |= LEAF;
171 if(curtext->mark & LEAF) {
172 if(curtext->from.sym)
173 curtext->from.sym->type = SLEAF;
179 q->from.type = D_CONST;
180 q->from.offset = autosize;
198 q1->from.type = D_REG;
199 q1->from.reg = REGLINK;
200 q1->to.type = D_OREG;
201 q1->to.offset = -autosize;
210 if(p->from.type == D_CONST)
212 if(curtext->mark & LEAF) {
224 p->from.type = D_CONST;
225 p->from.offset = autosize;
245 p->from.type = D_OREG;
246 p->from.offset = autosize;
253 if(curtext->mark & LEAF) {
274 p->from.type = D_CONST;
275 p->from.offset = autosize;
296 p->from.type = D_OREG;
297 p->from.offset = autosize;
306 * 5c code generation for unsigned -> double made the
307 * unfortunate assumption that single and double floating
308 * point registers are aliased - true for emulated 7500
309 * but not for vfp. Now corrected, but this test is
310 * insurance against old 5c compiled code in libraries.
313 if((q = p->link) != P && q->as == ACMP)
314 if((q = q->link) != P && q->as == AMOVF)
315 if((q1 = q->link) != P && q1->as == AADDF)
316 if(q1->to.type == D_FREG && q1->to.reg == p->to.reg) {
319 q1->scond = q->scond;
335 if(p->from.type != D_REG)
337 if(p->to.type != D_REG)
349 p->from.type = D_REG;
350 p->from.reg = q1->from.reg;
363 p->from.type = D_REG;
364 p->from.reg = q1->reg;
366 p->from.reg = q1->to.reg;
371 /* CALL appropriate */
379 p->to.type = D_BRANCH;
388 p->to.sym = sym_divu;
396 p->to.sym = sym_modu;
408 p->from.type = D_REG;
409 p->from.reg = REGTMP;
412 p->to.reg = q1->to.reg;
421 p->from.type = D_CONST;
430 q1->from.type = D_CONST;
447 if(s->type == STEXT){
451 else if(s->type == 0 || s->type == SXREF)
467 if(s->type == 0 || s->type == SXREF){
472 s->subtype = SIMPORT;
474 else if(s->type != STEXT)
475 diag("undefined: %s", s->name);
481 Sym *s2, *s3, *s4, *s5;
486 sym_div = s2 = lookup("_div", 0);
487 sym_divu = s3 = lookup("_divu", 0);
488 sym_mod = s4 = lookup("_mod", 0);
489 sym_modu = s5 = lookup("_modu", 0);
491 sdiv(s2); if(s2->type == SXREF) prog_div = UP;
492 sdiv(s3); if(s3->type == SXREF) prog_divu = UP;
493 sdiv(s4); if(s4->type == SXREF) prog_mod = UP;
494 sdiv(s5); if(s5->type == SXREF) prog_modu = UP;
496 for(p = firstp; p != P; p = p->link)
498 if(p->from.sym == s2)
500 if(p->from.sym == s3)
502 if(p->from.sym == s4)
504 if(p->from.sym == s5)
508 diag("undefined: %s", s2->name);
512 diag("undefined: %s", s3->name);
516 diag("undefined: %s", s4->name);
520 diag("undefined: %s", s5->name);