1
0
mirror of https://github.com/golang/go synced 2024-11-25 14:07:56 -07:00

cgen_asop sudoaddable

R=rsc
APPROVED=rsc
DELTA=14  (4 added, 0 deleted, 10 changed)
OCL=35190
CL=35210
This commit is contained in:
Kai Backman 2009-10-01 06:50:59 -07:00
parent a1b4796394
commit 8fd53f4754
2 changed files with 62 additions and 22 deletions

View File

@ -111,7 +111,7 @@ void
ginscall(Node *f, int proc)
{
Prog *p;
// Node reg, con;
Node n1, r, con;
switch(proc) {
default:
@ -125,17 +125,53 @@ ginscall(Node *f, int proc)
case 1: // call in new proc (go)
case 2: // defered call (defer)
fatal("ginscall new proc/defered not implemented");
// nodreg(&reg, types[TINT64], D_AX);
// gins(APUSHQ, f, N);
// nodconst(&con, types[TINT32], argsize(f->type));
// gins(APUSHQ, &con, N);
// if(proc == 1)
// ginscall(newproc, 0);
// else
// ginscall(deferproc, 0);
// gins(APOPQ, N, &reg);
// gins(APOPQ, N, &reg);
regalloc(&r, types[tptr], N);
p = gins(AMOVW, N, &r);
p->from.type = D_OREG;
p->from.reg = REGSP;
p = gins(AMOVW, &r, N);
p->to.type = D_OREG;
p->to.reg = REGSP;
p->to.offset = -8;
p->scond |= C_WBIT;
memset(&n1, 0, sizeof n1);
n1.op = OADDR;
n1.left = f;
gins(AMOVW, &n1, &r);
p = gins(AMOVW, &r, N);
p->to.type = D_OREG;
p->to.reg = REGSP;
p->to.offset = 8;
nodconst(&con, types[TINT32], argsize(f->type));
gins(AMOVW, &con, &r);
p = gins(AMOVW, &r, N);
p->to.type = D_OREG;
p->to.reg = REGSP;
p->to.offset = 4;
regfree(&r);
if(proc == 1)
ginscall(newproc, 0);
else
ginscall(deferproc, 0);
regalloc(&r, types[tptr], N);
p = gins(AMOVW, N, &r);
p->from.type = D_OREG;
p->from.reg = REGSP;
p->from.offset = 0;
p = gins(AMOVW, &r, N);
p->to.type = D_OREG;
p->to.reg = REGSP;
p->to.offset = 8;
p->scond |= C_WBIT;
regfree(&r);
break;
}
}
@ -338,7 +374,7 @@ cgen_asop(Node *n)
{
Node n1, n2, n3, n4;
Node *nl, *nr;
// Prog *p1;
Prog *p1;
Addr addr;
int a, w;
@ -379,15 +415,18 @@ cgen_asop(Node *n)
}
if(nr->ullman < UINF)
if(sudoaddable(a, nl, &addr, &w)) {
fatal("cgen_asop sudoaddable not implemented");
// regalloc(&n2, nr->type, N);
// cgen(nr, &n2);
// p1 = gins(a, &n2, N);
// p1->to = addr;
// p1->reg = w;
// regfree(&n2);
// sudoclean();
// goto ret;
regalloc(&n2, nl->type, N);
regalloc(&n3, nr->type, N);
p1 = gins(AMOVW, N, &n2);
p1->from = addr;
cgen(nr, &n3);
gins(a, &n3, &n2);
p1 = gins(AMOVW, &n2, N);
p1->to = addr;
regfree(&n2);
regfree(&n3);
sudoclean();
goto ret;
}
}

View File

@ -192,6 +192,7 @@ func2.go
func3.go
func4.go
gc1.go
hashmap.go
helloworld.go
if.go
import1.go