1
0
mirror of https://github.com/golang/go synced 2024-11-22 08:04:39 -07:00

better version of op=

fixed bugs in /= and %/

SVN=122493
This commit is contained in:
Ken Thompson 2008-06-12 14:21:09 -07:00
parent dbf1da6b37
commit ef61a4cb1e
2 changed files with 25 additions and 25 deletions

View File

@ -275,7 +275,7 @@ loop:
break; break;
case OASOP: case OASOP:
cgen_asop(n->left, n->right, n->etype); cgen_asop(n);
break; break;
case OAS: case OAS:
@ -683,40 +683,40 @@ cgen_ret(Node *n)
} }
void void
cgen_asop(Node *nl, Node *nr, int op) cgen_asop(Node *n)
{ {
Node n1, n2; Node n1, n2, n3, n4;
int a; Node *nl, *nr;
nl = n->left;
nr = n->right;
if(nr->ullman >= UINF && nl->ullman >= UINF) { if(nr->ullman >= UINF && nl->ullman >= UINF) {
fatal("cgen_asop both sides call"); fatal("cgen_asop both sides call");
} }
// BOTCH make special case for DIVQ
a = optoas(op, nl->type);
if(nl->addable) {
regalloc(&n2, nr->type, N);
cgen(nr, &n2);
regalloc(&n1, nl->type, N);
cgen(nl, &n1);
gins(a, &n2, &n1);
gmove(&n1, nl);
regfree(&n1);
regfree(&n2);
return;
}
if(nr->ullman > nl->ullman) { if(nr->ullman > nl->ullman) {
fatal("gcgen_asopen"); regalloc(&n2, nl->type, N);
cgen(nr, &n2);
igen(nl, &n1, N);
} else {
igen(nl, &n1, N);
regalloc(&n2, nl->type, N);
cgen(nr, &n2);
} }
regalloc(&n1, nl->type, N); n3 = *n;
igen(nl, &n2, N); n3.left = &n1;
cgen(nr, &n1); n3.right = &n2;
gins(a, &n1, &n2); n3.op = n->etype;
regalloc(&n4, nr->type, N);
cgen(&n3, &n4);
gmove(&n4, &n1);
regfree(&n1); regfree(&n1);
regfree(&n2); regfree(&n2);
regfree(&n4);
} }
void void

View File

@ -109,7 +109,7 @@ Node* lookdot(Node*, Node*, int);
void inarggen(void); void inarggen(void);
void agen_inter(Node*, Node*); void agen_inter(Node*, Node*);
void cgen_as(Node*, Node*, int); void cgen_as(Node*, Node*, int);
void cgen_asop(Node*, Node*, int); void cgen_asop(Node*);
void cgen_ret(Node*); void cgen_ret(Node*);
void cgen_call(Node*); void cgen_call(Node*);
void cgen_callmeth(Node*); void cgen_callmeth(Node*);