NODE * funcode(NODE *p) { NODE *r, *l; int reg = 0, stacksize = 0; r = l = 0; p->n_right = moveargs(p->n_right, ®, &stacksize); /* * This is a particularly gross and inefficient way to handle * argument overflows. First, we calculate how much stack space * we need in moveargs(). Then we assign it by moving %sp, make * the function call, and then move %sp back. * * What we should be doing is getting the maximum of all the needed * stacksize values to the prologue and doing it all in the "save" * instruction. */ if (stacksize != 0) { stacksize = V9STEP(stacksize); /* 16-bit alignment. */ r = block(REG, NIL, NIL, INT, 0, 0); r->n_lval = 0; r->n_rval = SP; r = block(MINUS, r, bcon(stacksize), INT, 0, 0); l = block(REG, NIL, NIL, INT, 0, 0); l->n_lval = 0; l->n_rval = SP; r = buildtree(ASSIGN, l, r); p = buildtree(COMOP, r, p); r = block(REG, NIL, NIL, INT, 0, 0); r->n_lval = 0; r->n_rval = SP; r = block(PLUS, r, bcon(stacksize), INT, 0, 0); l = block(REG, NIL, NIL, INT, 0, 0); l->n_lval = 0; l->n_rval = SP; r = buildtree(ASSIGN, l, r); p = buildtree(COMOP, p, r); } return p; }
void prologue(struct interpass_prolog *ipp) { int i, stack; stack = V9RESERVE + V9STEP(p2maxautooff); for (i = ipp->ipp_regs[0]; i; i >>= 1) if (i & 1) stack += 16; /* TODO printf("\t.proc %d\n"); */ if (SIMM13(stack)) printf("\tsave %%sp,-%d,%%sp\n", stack); else { printf("\tsetx -%d,%%g4,%%g1\n", stack); printf("\tsave %%sp,%%g1,%%sp\n"); } }