From: Russ Cox Date: Tue, 13 Jan 2009 21:46:09 +0000 (-0800) Subject: in 6g -r (the rsc flag), X-Git-Tag: weekly.2009-11-06~2386 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8fb60768c39ce4ad77068fb507a8beab306a1fd3;p=gostls13.git in 6g -r (the rsc flag), rewrite heap pointer moves as xchg. R=ken OCL=22665 CL=22665 --- diff --git a/src/cmd/6g/cgen.c b/src/cmd/6g/cgen.c index 4d6e11279d..43497adb21 100644 --- a/src/cmd/6g/cgen.c +++ b/src/cmd/6g/cgen.c @@ -7,6 +7,7 @@ /* * generate: * res = n; + * simplifies and calls gmove. */ void cgen(Node *n, Node *res) diff --git a/src/cmd/6g/gsubr.c b/src/cmd/6g/gsubr.c index 553abfa605..102e27d2e1 100644 --- a/src/cmd/6g/gsubr.c +++ b/src/cmd/6g/gsubr.c @@ -511,15 +511,49 @@ gmove(Node *f, Node *t) goto st; case TINT32: case TUINT32: - case TPTR32: a = AMOVL; goto st; case TINT64: case TUINT64: - case TPTR64: a = AMOVQ; goto st; + case TPTR32: + case TPTR64: + /* + * store to pointer. + */ + if(tt == TPTR32) + a = AMOVL; + else + a = AMOVQ; + switch(t->op) { + default: + dump("gmove to", t); + fatal("gmove t %O", t->op); + + case OINDREG: + if(t->val.u.reg != D_SP) + goto refcount; + break; + + case ONAME: + switch(t->class) { + default: + dump("gmove", t); + fatal("gmove t %O class %d reg %R", t->op, t->class, t->val.u.reg); + case PEXTERN: + case PSTATIC: + goto refcount; + break; + case PAUTO: + case PPARAM: + break; + } + break; + } + goto st; + st: if(f->op == OCONST) { gins(a, f, t); @@ -532,6 +566,22 @@ gmove(Node *f, Node *t) regfree(&nod); return; + refcount: + if(!debug['r']) + goto st; + // for now, mark ref count updates with AXCHGQ. + // using a temporary on the left, so no semantic + // changes. code is likely slower, but still correct. + if(t64) + a = AXCHGQ; + else + a = AXCHGL; + regalloc(&nod, t->type, f); + gmove(f, &nod); + gins(a, &nod, t); + regfree(&nod); + return; + case TFLOAT32: a = AMOVSS; goto fst; diff --git a/src/cmd/6g/reg.c b/src/cmd/6g/reg.c index 2efc0dc9bf..5b56138b34 100644 --- a/src/cmd/6g/reg.c +++ b/src/cmd/6g/reg.c @@ -182,6 +182,19 @@ regopt(Prog *firstp) for(z=0; zuse1.b[z] |= bit.b[z]; break; + + /* + * left side read+write + */ + case AXCHGB: + case AXCHGW: + case AXCHGL: + case AXCHGQ: + for(z=0; zuse1.b[z] |= bit.b[z]; + r->set.b[z] |= bit.b[z]; + } + break; } bit = mkvar(r, &p->to); @@ -313,6 +326,11 @@ regopt(Prog *firstp) case ASBBL: case ASBBQ: + case AXCHGB: + case AXCHGW: + case AXCHGL: + case AXCHGQ: + case AADDSD: case AADDSS: case ACMPSD: