From 28592ee1ea1f5cdffcf85472f9de0285d928cf12 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Wed, 3 Aug 2011 16:54:30 +0200 Subject: Imported Upstream version 59 --- src/cmd/6g/ggen.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/cmd/6g/ggen.c') diff --git a/src/cmd/6g/ggen.c b/src/cmd/6g/ggen.c index 5260335df..9e7fbab0d 100644 --- a/src/cmd/6g/ggen.c +++ b/src/cmd/6g/ggen.c @@ -18,6 +18,32 @@ defframe(Prog *ptxt) ptxt->to.offset |= rnd(stksize+maxarg, widthptr); } +// Sweep the prog list to mark any used nodes. +void +markautoused(Prog* p) +{ + for (; p; p = p->link) { + if (p->from.type == D_AUTO && p->from.node) + p->from.node->used++; + + if (p->to.type == D_AUTO && p->to.node) + p->to.node->used++; + } +} + +// Fixup instructions after compactframe has moved all autos around. +void +fixautoused(Prog* p) +{ + for (; p; p = p->link) { + if (p->from.type == D_AUTO && p->from.node) + p->from.offset += p->from.node->stkdelta; + + if (p->to.type == D_AUTO && p->to.node) + p->to.offset += p->to.node->stkdelta; + } +} + /* * generate: @@ -102,13 +128,13 @@ cgen_callinter(Node *n, Node *res, int proc) nodindreg(&nodsp, types[tptr], D_SP); nodo.xoffset += widthptr; - cgen(&nodo, &nodsp); // 0(SP) = 8(REG) -- i.s + cgen(&nodo, &nodsp); // 0(SP) = 8(REG) -- i.data nodo.xoffset -= widthptr; - cgen(&nodo, &nodr); // REG = 0(REG) -- i.m + cgen(&nodo, &nodr); // REG = 0(REG) -- i.tab nodo.xoffset = n->left->xoffset + 3*widthptr + 8; - cgen(&nodo, &nodr); // REG = 32+offset(REG) -- i.m->fun[f] + cgen(&nodo, &nodr); // REG = 32+offset(REG) -- i.tab->fun[f] // BOTCH nodr.type = fntype; nodr.type = n->left->type; -- cgit v1.2.3