aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-12-14 00:46:07 -0500
committerRuss Cox <rsc@golang.org>2011-12-14 00:46:07 -0500
commitc8a5f8841c816b105251919e244ddbd4ca5c38f1 (patch)
tree4e496b6b5ddb4ad8bef7d7e4bcb17fb36f3a7efd
parent1e63a4e4242389fdd1c5f90efa8c221c3bd2701b (diff)
downloadgo-c8a5f8841c816b105251919e244ddbd4ca5c38f1.tar.gz
go-c8a5f8841c816b105251919e244ddbd4ca5c38f1.zip
undo CL 5485063 / 21595dc0395a
breaks 64-bit build ««« original CL description 8c: handle 64-bit switch value Cases must still be 32-bit values, but one thing at a time. R=ality, ken2, ken CC=golang-dev https://golang.org/cl/5485063 »»» R=ken2 CC=golang-dev https://golang.org/cl/5488075
-rw-r--r--src/cmd/8c/swt.c50
-rw-r--r--src/cmd/cc/pgen.c12
2 files changed, 15 insertions, 47 deletions
diff --git a/src/cmd/8c/swt.c b/src/cmd/8c/swt.c
index 937a27d882..006bfdfe23 100644
--- a/src/cmd/8c/swt.c
+++ b/src/cmd/8c/swt.c
@@ -36,40 +36,12 @@ swit1(C1 *q, int nc, int32 def, Node *n)
C1 *r;
int i;
Prog *sp;
- Node n1, nreg, ncon;
-
- if(typev[n->type->etype]) {
- if(n->op != ONAME || n->sym != nodsafe->sym) {
- regsalloc(&nreg, n);
- nreg.type = types[TVLONG];
- cgen(n, &nreg);
- swit1(q, nc, def, &nreg);
- return;
- }
- } else {
- if(n->op != OREGISTER) {
- regalloc(&nreg, n, Z);
- nreg.type = types[TLONG];
- cgen(n, &nreg);
- swit1(q, nc, def, &nreg);
- regfree(&nreg);
- return;
- }
- }
if(nc < 5) {
for(i=0; i<nc; i++) {
if(debug['W'])
print("case = %.8ux\n", q->val);
- if(n->type && typev[n->type->etype]) {
- memset(&n1, 0, sizeof n1);
- n1.op = OEQ;
- n1.left = n;
- ncon = *nodconst(q->val);
- n1.right = &ncon;
- boolgen(&n1, 1, Z);
- } else
- gopcode(OEQ, n->type, n, nodconst(q->val));
+ gopcode(OEQ, n->type, n, nodconst(q->val));
patch(p, q->label);
q++;
}
@@ -81,22 +53,10 @@ swit1(C1 *q, int nc, int32 def, Node *n)
r = q+i;
if(debug['W'])
print("case > %.8ux\n", r->val);
- if(n->type && typev[n->type->etype]) {
- memset(&n1, 0, sizeof n1);
- n1.op = OGT;
- n1.left = n;
- ncon = *nodconst(r->val);
- n1.right = &ncon;
- boolgen(&n1, 1, Z);
- sp = p;
- n1.op = OEQ;
- boolgen(&n1, 1, Z);
- } else {
- gopcode(OGT, n->type, n, nodconst(r->val));
- sp = p;
- gbranch(OGOTO);
- p->as = AJEQ;
- }
+ gopcode(OGT, n->type, n, nodconst(r->val));
+ sp = p;
+ gbranch(OGOTO);
+ p->as = AJEQ;
patch(p, r->label);
swit1(q, i, def, n);
diff --git a/src/cmd/cc/pgen.c b/src/cmd/cc/pgen.c
index 3a686102f3..e652e2349d 100644
--- a/src/cmd/cc/pgen.c
+++ b/src/cmd/cc/pgen.c
@@ -293,7 +293,7 @@ loop:
complex(l);
if(l->type == T)
break;
- if(!typechlvp[l->type->etype] || l->type->etype == TIND) {
+ if(!typeword[l->type->etype] || l->type->etype == TIND) {
diag(n, "switch expression must be integer");
break;
}
@@ -320,7 +320,15 @@ loop:
}
patch(sp, pc);
- doswit(l);
+ regalloc(&nod, l, Z);
+ /* always signed */
+ if(typev[l->type->etype])
+ nod.type = types[TVLONG];
+ else
+ nod.type = types[TLONG];
+ cgen(l, &nod);
+ doswit(&nod);
+ regfree(&nod);
patch(spb, pc);
cases = cn;