maxstksize = 0;
}
+// Sweep the prog list to mark any used nodes.
+void
+markautoused(Prog* p)
+{
+ for (; p; p = p->link) {
+ if (p->from.name == D_AUTO && p->from.node)
+ p->from.node->used++;
+
+ if (p->to.name == 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.name == D_AUTO && p->from.node)
+ p->from.offset += p->from.node->stkdelta;
+
+ if (p->to.name == D_AUTO && p->to.node)
+ p->to.offset += p->to.node->stkdelta;
+ }
+}
+
/*
* generate:
* call f
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:
maxstksize = 0;
}
+// 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;
+ }
+}
+
void
clearfat(Node *nl)
{
void walkstmtlist(NodeList *l);
/*
- * arch-specific ggen.c/gsubr.c/gobj.c
+ * arch-specific ggen.c/gsubr.c/gobj.c/pgen.c
*/
#define P ((Prog*)0)
int duintxx(Sym *s, int off, uint64 v, int wid);
void dumpdata(void);
void dumpfuncs(void);
+void fixautoused(Prog*);
void gdata(Node*, Node*, int);
void gdatacomplex(Node*, Mpcplx*);
void gdatastring(Node*, Strlit*);
Prog* gjmp(Prog*);
void gused(Node*);
int isfat(Type*);
+void markautoused(Prog*);
Plist* newplist(void);
Node* nodarg(Type*, int);
void nopout(Prog*);
}
oldstksize = stksize;
- if(thechar != '5')
- compactframe(ptxt);
+ compactframe(ptxt);
if(0)
print("compactframe: %ld to %ld\n", oldstksize, stksize);
}
+// TODO(lvd) find out where the PAUTO/OLITERAL nodes come from.
static void
compactframe(Prog* ptxt)
{
NodeList *ll;
Node* n;
- Prog *p;
uint32 w;
if (stksize == 0)
// Mark the PAUTO's unused.
for(ll=curfn->dcl; ll != nil; ll=ll->next)
- if (ll->n->class == PAUTO && ll->n->op == ONAME)
+ if (ll->n->class == PAUTO)
ll->n->used = 0;
- // Sweep the prog list to mark any used nodes.
- for (p = ptxt; 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++;
- }
+ markautoused(ptxt);
listsort(&curfn->dcl, cmpstackvar);
stksize = 0;
for(ll = curfn->dcl; ll != nil; ll=ll->next) {
n = ll->n;
- // TODO find out where the literal autos come from
if (n->class != PAUTO || n->op != ONAME)
continue;
n->stkdelta = -stksize - n->xoffset;
}
- // Fixup instructions.
- for (p = ptxt; 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;
- }
+ fixautoused(ptxt);
// The debug information needs accurate offsets on the symbols.
for(ll = curfn->dcl ;ll != nil; ll=ll->next) {