1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00

[dev.power64] cmd/9g: use loops to do memmove in sgen()

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/128130044
This commit is contained in:
Shenghou Ma 2014-08-13 01:22:34 -04:00
parent bc8d35a9cf
commit 372b5cebe7

View File

@ -1344,10 +1344,10 @@ stkof(Node *n)
void void
sgen(Node *n, Node *ns, int64 w) sgen(Node *n, Node *ns, int64 w)
{ {
Node dst, src, tmp; Node dst, src, tmp, nend;
int32 c, odst, osrc; int32 c, odst, osrc;
int dir, align, op; int dir, align, op;
Prog *p; Prog *p, *ploop;
NodeList *l; NodeList *l;
Node *res = ns; Node *res = ns;
@ -1447,19 +1447,15 @@ sgen(Node *n, Node *ns, int64 w)
regalloc(&tmp, types[tptr], N); regalloc(&tmp, types[tptr], N);
// set up end marker // set up end marker
//memset(&nend, 0, sizeof nend); memset(&nend, 0, sizeof nend);
//if(c >= 4) {
// regalloc(&nend, types[tptr], N);
// p = gins(AMOVD, &src, &nend);
// p->from.type = D_CONST;
// if(dir < 0)
// p->from.offset = dir;
// else
// p->from.offset = w;
//}
// move src and dest to the end of block if necessary // move src and dest to the end of block if necessary
if(dir < 0) { if(dir < 0) {
if(c >= 4) {
regalloc(&nend, types[tptr], N);
p = gins(AMOVD, &src, &nend);
}
p = gins(AADD, N, &src); p = gins(AADD, N, &src);
p->from.type = D_CONST; p->from.type = D_CONST;
p->from.offset = w; p->from.offset = w;
@ -1475,11 +1471,19 @@ sgen(Node *n, Node *ns, int64 w)
p = gins(AADD, N, &dst); p = gins(AADD, N, &dst);
p->from.type = D_CONST; p->from.type = D_CONST;
p->from.offset = -dir; p->from.offset = -dir;
if(c >= 4) {
regalloc(&nend, types[tptr], N);
p = gins(AMOVD, &src, &nend);
p->from.type = D_CONST;
p->from.offset = w;
}
} }
// move // move
// TODO: enable loops and duffcopy for larger copies. // TODO: enable duffcopy for larger copies.
/*if(c >= 4) { if(c >= 4) {
p = gins(op, &src, &tmp); p = gins(op, &src, &tmp);
p->from.type = D_OREG; p->from.type = D_OREG;
p->from.offset = dir; p->from.offset = dir;
@ -1489,12 +1493,11 @@ sgen(Node *n, Node *ns, int64 w)
p->to.type = D_OREG; p->to.type = D_OREG;
p->to.offset = dir; p->to.offset = dir;
p = gins(ACMP, &src, N); p = gins(ACMP, &src, &nend);
raddr(&nend, p);
patch(gbranch(ABNE, T, 0), ploop); patch(gbranch(ABNE, T, 0), ploop);
regfree(&nend); regfree(&nend);
} else*/ { } else {
while(c-- > 0) { while(c-- > 0) {
p = gins(op, &src, &tmp); p = gins(op, &src, &tmp);
p->from.type = D_OREG; p->from.type = D_OREG;