From b8a3e88ea73fded96fe9f5a72b4b3032bf2873ed Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 3 Feb 2015 15:27:54 -0500 Subject: [PATCH] cmd/gc: remove cgen_asop, no longer used gc/order.c rewrites OASOP nodes into ordinary assignments. The back ends never see them anymore. Change-Id: I268ac8bdc92dccd7123110a21f99ada3ceeb2baa Reviewed-on: https://go-review.googlesource.com/3882 Reviewed-by: Austin Clements --- src/cmd/5g/galign.c | 1 - src/cmd/5g/gg.h | 1 - src/cmd/5g/ggen.c | 129 ---------------------------------------- src/cmd/6g/galign.c | 1 - src/cmd/6g/gg.h | 1 - src/cmd/6g/ggen.c | 139 -------------------------------------------- src/cmd/8g/galign.c | 1 - src/cmd/8g/gg.h | 1 - src/cmd/8g/ggen.c | 136 ------------------------------------------- src/cmd/9g/galign.c | 1 - src/cmd/9g/gg.h | 1 - src/cmd/9g/ggen.c | 7 --- src/cmd/gc/gen.c | 4 -- src/cmd/gc/go.h | 1 - 14 files changed, 424 deletions(-) diff --git a/src/cmd/5g/galign.c b/src/cmd/5g/galign.c index 1af6df06a8..c136406a79 100644 --- a/src/cmd/5g/galign.c +++ b/src/cmd/5g/galign.c @@ -53,7 +53,6 @@ main(int argc, char **argv) arch.betypeinit = betypeinit; arch.bgen = bgen; arch.cgen = cgen; - arch.cgen_asop = cgen_asop; arch.cgen_call = cgen_call; arch.cgen_callinter = cgen_callinter; arch.cgen_ret = cgen_ret; diff --git a/src/cmd/5g/gg.h b/src/cmd/5g/gg.h index 912c224b31..210c9c2cc7 100644 --- a/src/cmd/5g/gg.h +++ b/src/cmd/5g/gg.h @@ -115,7 +115,6 @@ int anyregalloc(void); void betypeinit(void); void bgen(Node*, int, int, Prog*); void cgen(Node*, Node*); -void cgen_asop(Node*); void cgen_call(Node*, int); void cgen_callinter(Node*, Node*, int); void cgen_ret(Node*); diff --git a/src/cmd/5g/ggen.c b/src/cmd/5g/ggen.c index e65523730b..f91cd71518 100644 --- a/src/cmd/5g/ggen.c +++ b/src/cmd/5g/ggen.c @@ -437,135 +437,6 @@ cgen_ret(Node *n) } } -/* - * generate += *= etc. - */ -void -cgen_asop(Node *n) -{ - Node n1, n2, n3, n4; - Node *nl, *nr; - Prog *p1; - Addr addr; - int a, w; - - nl = n->left; - nr = n->right; - - if(nr->ullman >= UINF && nl->ullman >= UINF) { - tempname(&n1, nr->type); - cgen(nr, &n1); - n2 = *n; - n2.right = &n1; - cgen_asop(&n2); - goto ret; - } - - if(!isint[nl->type->etype]) - goto hard; - if(!isint[nr->type->etype]) - goto hard; - if(is64(nl->type) || is64(nr->type)) - goto hard64; - - switch(n->etype) { - case OADD: - case OSUB: - case OXOR: - case OAND: - case OOR: - a = optoas(n->etype, nl->type); - if(nl->addable) { - if(smallintconst(nr)) - n3 = *nr; - else { - regalloc(&n3, nr->type, N); - cgen(nr, &n3); - } - regalloc(&n2, nl->type, N); - cgen(nl, &n2); - gins(a, &n3, &n2); - cgen(&n2, nl); - regfree(&n2); - if(n3.op != OLITERAL) - regfree(&n3); - goto ret; - } - if(nr->ullman < UINF) - if(sudoaddable(a, nl, &addr, &w)) { - w = optoas(OAS, nl->type); - regalloc(&n2, nl->type, N); - p1 = gins(w, N, &n2); - p1->from = addr; - regalloc(&n3, nr->type, N); - cgen(nr, &n3); - gins(a, &n3, &n2); - p1 = gins(w, &n2, N); - p1->to = addr; - regfree(&n2); - regfree(&n3); - sudoclean(); - goto ret; - } - } - -hard: - n2.op = 0; - n1.op = 0; - if(nr->op == OLITERAL) { - // don't allocate a register for literals. - } else if(nr->ullman >= nl->ullman || nl->addable) { - regalloc(&n2, nr->type, N); - cgen(nr, &n2); - nr = &n2; - } else { - tempname(&n2, nr->type); - cgen(nr, &n2); - nr = &n2; - } - if(!nl->addable) { - igen(nl, &n1, N); - nl = &n1; - } - - n3 = *n; - n3.left = nl; - n3.right = nr; - n3.op = n->etype; - - regalloc(&n4, nl->type, N); - cgen(&n3, &n4); - gmove(&n4, nl); - - if(n1.op) - regfree(&n1); - if(n2.op == OREGISTER) - regfree(&n2); - regfree(&n4); - goto ret; - -hard64: - if(nr->ullman > nl->ullman) { - tempname(&n2, nr->type); - cgen(nr, &n2); - igen(nl, &n1, N); - } else { - igen(nl, &n1, N); - tempname(&n2, nr->type); - cgen(nr, &n2); - } - - n3 = *n; - n3.left = &n1; - n3.right = &n2; - n3.op = n->etype; - - cgen(&n3, &n1); - -ret: - ; -} - /* * generate high multiply * res = (nl * nr) >> wordsize diff --git a/src/cmd/6g/galign.c b/src/cmd/6g/galign.c index 58de9ae7bc..71ad402cd5 100644 --- a/src/cmd/6g/galign.c +++ b/src/cmd/6g/galign.c @@ -76,7 +76,6 @@ main(int argc, char **argv) arch.betypeinit = betypeinit; arch.bgen = bgen; arch.cgen = cgen; - arch.cgen_asop = cgen_asop; arch.cgen_call = cgen_call; arch.cgen_callinter = cgen_callinter; arch.cgen_ret = cgen_ret; diff --git a/src/cmd/6g/gg.h b/src/cmd/6g/gg.h index 0167a3fa0f..789a9870ea 100644 --- a/src/cmd/6g/gg.h +++ b/src/cmd/6g/gg.h @@ -114,7 +114,6 @@ int anyregalloc(void); void betypeinit(void); void bgen(Node*, int, int, Prog*); void cgen(Node*, Node*); -void cgen_asop(Node*); void cgen_call(Node*, int); void cgen_callinter(Node*, Node*, int); void cgen_ret(Node*); diff --git a/src/cmd/6g/ggen.c b/src/cmd/6g/ggen.c index f1d5cf2c1d..dd61812bcd 100644 --- a/src/cmd/6g/ggen.c +++ b/src/cmd/6g/ggen.c @@ -431,145 +431,6 @@ cgen_ret(Node *n) } } -/* - * generate += *= etc. - */ -void -cgen_asop(Node *n) -{ - Node n1, n2, n3, n4; - Node *nl, *nr; - Prog *p1; - Addr addr; - int a; - - nl = n->left; - nr = n->right; - - if(nr->ullman >= UINF && nl->ullman >= UINF) { - tempname(&n1, nr->type); - cgen(nr, &n1); - n2 = *n; - n2.right = &n1; - cgen_asop(&n2); - goto ret; - } - - if(!isint[nl->type->etype]) - goto hard; - if(!isint[nr->type->etype]) - goto hard; - - switch(n->etype) { - case OADD: - if(smallintconst(nr)) - if(mpgetfix(nr->val.u.xval) == 1) { - a = optoas(OINC, nl->type); - if(nl->addable) { - gins(a, N, nl); - goto ret; - } - if(sudoaddable(a, nl, &addr)) { - p1 = gins(a, N, N); - p1->to = addr; - sudoclean(); - goto ret; - } - } - break; - - case OSUB: - if(smallintconst(nr)) - if(mpgetfix(nr->val.u.xval) == 1) { - a = optoas(ODEC, nl->type); - if(nl->addable) { - gins(a, N, nl); - goto ret; - } - if(sudoaddable(a, nl, &addr)) { - p1 = gins(a, N, N); - p1->to = addr; - sudoclean(); - goto ret; - } - } - break; - } - - switch(n->etype) { - case OADD: - case OSUB: - case OXOR: - case OAND: - case OOR: - a = optoas(n->etype, nl->type); - if(nl->addable) { - if(smallintconst(nr)) { - gins(a, nr, nl); - goto ret; - } - regalloc(&n2, nr->type, N); - cgen(nr, &n2); - gins(a, &n2, nl); - regfree(&n2); - goto ret; - } - if(nr->ullman < UINF) - if(sudoaddable(a, nl, &addr)) { - if(smallintconst(nr)) { - p1 = gins(a, nr, N); - p1->to = addr; - sudoclean(); - goto ret; - } - regalloc(&n2, nr->type, N); - cgen(nr, &n2); - p1 = gins(a, &n2, N); - p1->to = addr; - regfree(&n2); - sudoclean(); - goto ret; - } - } - -hard: - n2.op = 0; - n1.op = 0; - if(nr->op == OLITERAL) { - // don't allocate a register for literals. - } else if(nr->ullman >= nl->ullman || nl->addable) { - regalloc(&n2, nr->type, N); - cgen(nr, &n2); - nr = &n2; - } else { - tempname(&n2, nr->type); - cgen(nr, &n2); - nr = &n2; - } - if(!nl->addable) { - igen(nl, &n1, N); - nl = &n1; - } - - n3 = *n; - n3.left = nl; - n3.right = nr; - n3.op = n->etype; - - regalloc(&n4, nl->type, N); - cgen(&n3, &n4); - gmove(&n4, nl); - - if(n1.op) - regfree(&n1); - if(n2.op == OREGISTER) - regfree(&n2); - regfree(&n4); - -ret: - ; -} - /* * generate division. * generates one of: diff --git a/src/cmd/8g/galign.c b/src/cmd/8g/galign.c index c06552c02d..3fb48ad5e4 100644 --- a/src/cmd/8g/galign.c +++ b/src/cmd/8g/galign.c @@ -53,7 +53,6 @@ main(int argc, char **argv) arch.betypeinit = betypeinit; arch.bgen = bgen; arch.cgen = cgen; - arch.cgen_asop = cgen_asop; arch.cgen_call = cgen_call; arch.cgen_callinter = cgen_callinter; arch.cgen_ret = cgen_ret; diff --git a/src/cmd/8g/gg.h b/src/cmd/8g/gg.h index 5217cdc230..46a61b4d1c 100644 --- a/src/cmd/8g/gg.h +++ b/src/cmd/8g/gg.h @@ -127,7 +127,6 @@ int anyregalloc(void); void betypeinit(void); void bgen(Node*, int, int, Prog*); void cgen(Node*, Node*); -void cgen_asop(Node*); void cgen_call(Node*, int); void cgen_callinter(Node*, Node*, int); void cgen_ret(Node*); diff --git a/src/cmd/8g/ggen.c b/src/cmd/8g/ggen.c index 475a5fd0e4..4cd159edcd 100644 --- a/src/cmd/8g/ggen.c +++ b/src/cmd/8g/ggen.c @@ -478,142 +478,6 @@ cgen_ret(Node *n) } } -/* - * generate += *= etc. - */ -void -cgen_asop(Node *n) -{ - Node n1, n2, n3, n4; - Node *nl, *nr; - Prog *p1; - Addr addr; - int a; - - nl = n->left; - nr = n->right; - - if(nr->ullman >= UINF && nl->ullman >= UINF) { - tempname(&n1, nr->type); - cgen(nr, &n1); - n2 = *n; - n2.right = &n1; - cgen_asop(&n2); - goto ret; - } - - if(!isint[nl->type->etype]) - goto hard; - if(!isint[nr->type->etype]) - goto hard; - if(is64(nl->type) || is64(nr->type)) - goto hard; - - switch(n->etype) { - case OADD: - if(smallintconst(nr)) - if(mpgetfix(nr->val.u.xval) == 1) { - a = optoas(OINC, nl->type); - if(nl->addable) { - gins(a, N, nl); - goto ret; - } - if(sudoaddable(a, nl, &addr)) { - p1 = gins(a, N, N); - p1->to = addr; - sudoclean(); - goto ret; - } - } - break; - - case OSUB: - if(smallintconst(nr)) - if(mpgetfix(nr->val.u.xval) == 1) { - a = optoas(ODEC, nl->type); - if(nl->addable) { - gins(a, N, nl); - goto ret; - } - if(sudoaddable(a, nl, &addr)) { - p1 = gins(a, N, N); - p1->to = addr; - sudoclean(); - goto ret; - } - } - break; - } - - switch(n->etype) { - case OADD: - case OSUB: - case OXOR: - case OAND: - case OOR: - a = optoas(n->etype, nl->type); - if(nl->addable) { - if(smallintconst(nr)) { - gins(a, nr, nl); - goto ret; - } - regalloc(&n2, nr->type, N); - cgen(nr, &n2); - gins(a, &n2, nl); - regfree(&n2); - goto ret; - } - if(nr->ullman < UINF) - if(sudoaddable(a, nl, &addr)) { - if(smallintconst(nr)) { - p1 = gins(a, nr, N); - p1->to = addr; - sudoclean(); - goto ret; - } - regalloc(&n2, nr->type, N); - cgen(nr, &n2); - p1 = gins(a, &n2, N); - p1->to = addr; - regfree(&n2); - sudoclean(); - goto ret; - } - } - -hard: - n2.op = 0; - n1.op = 0; - if(nr->ullman >= nl->ullman || nl->addable) { - mgen(nr, &n2, N); - nr = &n2; - } else { - tempname(&n2, nr->type); - cgen(nr, &n2); - nr = &n2; - } - if(!nl->addable) { - igen(nl, &n1, N); - nl = &n1; - } - - n3 = *n; - n3.left = nl; - n3.right = nr; - n3.op = n->etype; - - mgen(&n3, &n4, N); - gmove(&n4, nl); - - if(n1.op) - regfree(&n1); - mfree(&n2); - mfree(&n4); - -ret: - ; -} - /* * generate division. * caller must set: diff --git a/src/cmd/9g/galign.c b/src/cmd/9g/galign.c index 71c869fe4e..39db87d48a 100644 --- a/src/cmd/9g/galign.c +++ b/src/cmd/9g/galign.c @@ -60,7 +60,6 @@ main(int argc, char **argv) arch.betypeinit = betypeinit; arch.bgen = bgen; arch.cgen = cgen; - arch.cgen_asop = cgen_asop; arch.cgen_call = cgen_call; arch.cgen_callinter = cgen_callinter; arch.cgen_ret = cgen_ret; diff --git a/src/cmd/9g/gg.h b/src/cmd/9g/gg.h index bf5d00299e..235b8b9731 100644 --- a/src/cmd/9g/gg.h +++ b/src/cmd/9g/gg.h @@ -109,7 +109,6 @@ int anyregalloc(void); void betypeinit(void); void bgen(Node*, int, int, Prog*); void cgen(Node*, Node*); -void cgen_asop(Node*); void cgen_call(Node*, int); void cgen_callinter(Node*, Node*, int); void cgen_ret(Node*); diff --git a/src/cmd/9g/ggen.c b/src/cmd/9g/ggen.c index 0340e1d7c2..7e8efb5048 100644 --- a/src/cmd/9g/ggen.c +++ b/src/cmd/9g/ggen.c @@ -442,13 +442,6 @@ cgen_ret(Node *n) } } -void -cgen_asop(Node *n) -{ - USED(n); - fatal("cgen_asop"); // no longer used -} - /* * generate division. * generates one of: diff --git a/src/cmd/gc/gen.c b/src/cmd/gc/gen.c index f1a020152b..e600c1e5ea 100644 --- a/src/cmd/gc/gen.c +++ b/src/cmd/gc/gen.c @@ -453,10 +453,6 @@ gen(Node *n) lab->breakpc = P; break; - case OASOP: - arch.cgen_asop(n); - break; - case ODCL: cgen_dcl(n->left); break; diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h index a89055170e..0674b2ce6b 100644 --- a/src/cmd/gc/go.h +++ b/src/cmd/gc/go.h @@ -1666,7 +1666,6 @@ struct Arch void (*betypeinit)(void); void (*bgen)(Node*, int, int, Prog*); void (*cgen)(Node*, Node*); - void (*cgen_asop)(Node*); void (*cgen_call)(Node*, int); void (*cgen_callinter)(Node*, Node*, int); void (*cgen_ret)(Node*);