1
0
mirror of https://github.com/golang/go synced 2024-11-21 20:04:44 -07:00

gc: frame compaction for arm.

Required moving some parts of gc/pgen.c to ?g/ggen.c

on linux tests pass for all 3 architectures, and
frames are actually compacted (diagnostic code for
that has been removed from the CL).

R=rsc
CC=golang-dev
https://golang.org/cl/4571071
This commit is contained in:
Luuk van Dijk 2011-06-14 17:03:37 +02:00
parent 4d0f2e9195
commit 2ad42a8249
5 changed files with 86 additions and 22 deletions

View File

@ -22,6 +22,32 @@ defframe(Prog *ptxt)
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

View File

@ -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:

View File

@ -20,6 +20,32 @@ defframe(Prog *ptxt)
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)
{

View File

@ -1195,7 +1195,7 @@ void walkstmt(Node **np);
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)
@ -1237,6 +1237,7 @@ int dsymptr(Sym *s, int off, Sym *x, int xoff);
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*);
@ -1246,6 +1247,7 @@ void ggloblsym(Sym *s, int32 width, int dupok);
Prog* gjmp(Prog*);
void gused(Node*);
int isfat(Type*);
void markautoused(Prog*);
Plist* newplist(void);
Node* nodarg(Type*, int);
void nopout(Prog*);

View File

@ -111,7 +111,6 @@ compile(Node *fn)
}
oldstksize = stksize;
if(thechar != '5')
compactframe(ptxt);
if(0)
print("compactframe: %ld to %ld\n", oldstksize, stksize);
@ -142,12 +141,12 @@ cmpstackvar(Node *a, Node *b)
}
// 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)
@ -155,17 +154,10 @@ compactframe(Prog* ptxt)
// 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);
@ -191,7 +183,6 @@ compactframe(Prog* ptxt)
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;
@ -205,14 +196,7 @@ compactframe(Prog* ptxt)
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) {