From 0b5dd8859d5c65d294f470223ea15c0b7016ebf2 Mon Sep 17 00:00:00 2001 From: Kai Backman Date: Fri, 26 Jun 2009 22:04:30 -0700 Subject: working on bgen - removed smallint optimizations - lifted raddr from 5c - add back %R, was used in gc/* causing -g to crash - changed naddr OREGISTER to emit D_REG instead of D_OREG R=rsc APPROVED=rsc DELTA=74 (38 added, 28 deleted, 8 changed) OCL=30799 CL=30822 --- src/cmd/5g/cgen.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) (limited to 'src/cmd/5g/cgen.c') diff --git a/src/cmd/5g/cgen.c b/src/cmd/5g/cgen.c index 443c2ca3a..70b8ccf6a 100644 --- a/src/cmd/5g/cgen.c +++ b/src/cmd/5g/cgen.c @@ -14,7 +14,7 @@ cgen(Node *n, Node *res) { Node *nl, *nr, *r; Node n1, n2; - int a, f; + int a; Prog *p1, *p2, *p3; Addr addr; @@ -68,20 +68,9 @@ cgen(Node *n, Node *res) if(res->ullman >= UINF) goto gen; - f = 1; // gen thru register - switch(n->op) { - case OLITERAL: - if(smallintconst(n)) - f = 0; - break; - case OREGISTER: - f = 0; - break; - } - a = optoas(OAS, res->type); if(sudoaddable(a, res, &addr)) { - if(f) { + if(n->op != OREGISTER) { regalloc(&n2, res->type, N); cgen(n, &n2); p1 = gins(a, &n2, N); @@ -224,7 +213,8 @@ cgen(Node *n, Node *res) cgen(nl, &n1); nodconst(&n2, types[tptr], 0); - gins(optoas(OCMP, types[tptr]), &n1, &n2); + p1 = gins(optoas(OCMP, types[tptr]), &n1, N); + raddr(&n2, p1); p1 = gbranch(optoas(OEQ, types[tptr]), T); n2 = n1; @@ -601,7 +591,7 @@ bgen(Node *n, int true, Prog *to) { int et, a; Node *nl, *nr, *r; - Node n1, n2, tmp; + Node n1, n2, n3, tmp; Prog *p1, *p2; if(debug['g']) { @@ -635,12 +625,16 @@ bgen(Node *n, int true, Prog *to) regalloc(&n1, n->type, N); cgen(n, &n1); nodconst(&n2, n->type, 0); - gins(optoas(OCMP, n->type), &n1, &n2); - a = ABNE; + regalloc(&n3, n->type, N); + cgen(&n2, &n3); + p1 = gins(optoas(OCMP, n->type), &n1, N); + raddr(&n3, p1); + a = ABNE; if(!true) a = ABEQ; patch(gbranch(a, n->type), to); regfree(&n1); + regfree(&n3); goto ret; case OLITERAL: @@ -770,17 +764,11 @@ bgen(Node *n, int true, Prog *to) regalloc(&n1, nl->type, N); cgen(nl, &n1); - if(smallintconst(nr)) { - gins(optoas(OCMP, nr->type), &n1, nr); - patch(gbranch(a, nr->type), to); - regfree(&n1); - break; - } - regalloc(&n2, nr->type, N); cgen(nr, &n2); - gins(optoas(OCMP, nr->type), &n1, &n2); + p1 = gins(optoas(OCMP, nr->type), &n1, N); + raddr(&n2, p1); patch(gbranch(a, nr->type), to); regfree(&n1); -- cgit v1.2.3