7 int o, aoffset, 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;
51 /* special form of RETURN is BECOME */
52 if(p->from.type == D_CONST)
53 if(p->from.offset > curbecome)
54 curbecome = p->from.offset;
59 q->link = q1; /* q is non-nop */
65 curtext->mark &= ~LEAF;
94 case AADR: /* strange */
99 while(q1->as == ANOP) {
109 if(curtext && curtext->from.sym) {
110 curtext->from.sym->frame = curframe;
111 curtext->from.sym->become = curbecome;
112 if(curbecome > maxbecome)
113 maxbecome = curbecome;
117 print("max become = %d\n", maxbecome);
118 xdefine("ALEFbecome", STEXT, maxbecome);
121 for(p = firstp; p != P; p = p->link) {
127 if(curtext != P && curtext->from.sym != S && curtext->to.offset >= 0) {
128 o = maxbecome - curtext->from.sym->frame;
131 /* calling a become or calling a variable */
132 if(p->to.sym == S || p->to.sym->become) {
133 curtext->to.offset += o;
136 print("%D calling %D increase %d\n",
137 &curtext->from, &p->to, o);
145 for(p = firstp; p != P; p = p->link) {
153 autosize = p->to.offset + PCSZ;
154 if((curtext->mark & LEAF) && autosize <= PCSZ)
156 else if(autosize & (STACKALIGN-1))
157 autosize += STACKALIGN - (autosize&(STACKALIGN-1));
158 p->to.offset = autosize - PCSZ;
160 if(autosize == 0 && !(curtext->mark & LEAF)) {
162 Bprint(&bso, "save suppressed in: %s\n",
163 curtext->from.sym->name);
165 curtext->mark |= LEAF;
172 if(curtext->mark & LEAF) {
173 if(curtext->from.sym)
174 curtext->from.sym->type = SLEAF;
181 if(autosize > aoffset){
185 q->from.type = D_CONST;
186 q->from.offset = autosize - aoffset;
192 if(curtext->mark & LEAF)
199 q1->from.type = D_REG;
200 q1->from.reg = REGLINK;
201 q1->to.type = D_XPRE;
202 q1->to.offset = -aoffset;
211 if(p->from.type == D_CONST)
213 if(curtext->mark & LEAF) {
216 p->from.type = D_CONST;
217 p->from.offset = autosize;
222 /* want write-back pre-indexed SP+autosize -> SP, loading REGLINK*/
228 p->from.type = D_XPOST;
229 p->from.offset = aoffset;
234 if(autosize > aoffset) {
237 q->from.type = D_CONST;
238 q->from.offset = autosize - aoffset;
248 if(p->as != ARETURN) {
265 if(curtext->mark & LEAF) {
285 p->from.type = D_CONST;
286 p->from.offset = autosize;
305 p->from.type = D_XPRE;
306 p->from.offset = -autosize;