mirror of
https://github.com/golang/go
synced 2024-11-18 18:24:48 -07:00
cmd/gc: remove several copies of outervalue
Walk calls it outervalue, racewalk calls it basenod, isstack does it manually and slightly differently. Change-Id: Id5b5d32b8faf143fe9d34bd08457bfab6fb33daa Reviewed-on: https://go-review.googlesource.com/3745 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
9568126f35
commit
c1bbf0a2ea
@ -24,7 +24,6 @@ static void racewalknode(Node **np, NodeList **init, int wr, int skip);
|
|||||||
static int callinstr(Node **n, NodeList **init, int wr, int skip);
|
static int callinstr(Node **n, NodeList **init, int wr, int skip);
|
||||||
static Node* uintptraddr(Node *n);
|
static Node* uintptraddr(Node *n);
|
||||||
static void makeaddable(Node *n);
|
static void makeaddable(Node *n);
|
||||||
static Node* basenod(Node *n);
|
|
||||||
static void foreach(Node *n, void(*f)(Node*, void*), void *c);
|
static void foreach(Node *n, void(*f)(Node*, void*), void *c);
|
||||||
static void hascallspred(Node *n, void *c);
|
static void hascallspred(Node *n, void *c);
|
||||||
static void appendinit(Node **np, NodeList *init);
|
static void appendinit(Node **np, NodeList *init);
|
||||||
@ -155,12 +154,8 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
|
|||||||
default:
|
default:
|
||||||
fatal("racewalk: unknown node type %O", n->op);
|
fatal("racewalk: unknown node type %O", n->op);
|
||||||
|
|
||||||
case OASOP:
|
|
||||||
case OAS:
|
case OAS:
|
||||||
case OAS2:
|
|
||||||
case OAS2RECV:
|
|
||||||
case OAS2FUNC:
|
case OAS2FUNC:
|
||||||
case OAS2MAPR:
|
|
||||||
racewalknode(&n->left, init, 1, 0);
|
racewalknode(&n->left, init, 1, 0);
|
||||||
racewalknode(&n->right, init, 0, 0);
|
racewalknode(&n->right, init, 0, 0);
|
||||||
goto ret;
|
goto ret;
|
||||||
@ -350,7 +345,7 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
|
|||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
case OEFACE:
|
case OEFACE:
|
||||||
racewalknode(&n->left, init, 0, 0);
|
// n->left is Type* which is not interesting.
|
||||||
racewalknode(&n->right, init, 0, 0);
|
racewalknode(&n->right, init, 0, 0);
|
||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
@ -393,6 +388,10 @@ racewalknode(Node **np, NodeList **init, int wr, int skip)
|
|||||||
case OARRAYLIT: // lowered to assignments
|
case OARRAYLIT: // lowered to assignments
|
||||||
case OMAPLIT:
|
case OMAPLIT:
|
||||||
case OSTRUCTLIT:
|
case OSTRUCTLIT:
|
||||||
|
case OAS2:
|
||||||
|
case OAS2RECV:
|
||||||
|
case OAS2MAPR:
|
||||||
|
case OASOP:
|
||||||
yyerror("racewalk: %O must be lowered by now", n->op);
|
yyerror("racewalk: %O must be lowered by now", n->op);
|
||||||
goto ret;
|
goto ret;
|
||||||
|
|
||||||
@ -489,7 +488,7 @@ callinstr(Node **np, NodeList **init, int wr, int skip)
|
|||||||
if(isartificial(n))
|
if(isartificial(n))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
b = basenod(n);
|
b = outervalue(n);
|
||||||
// it skips e.g. stores to ... parameter array
|
// it skips e.g. stores to ... parameter array
|
||||||
if(isartificial(b))
|
if(isartificial(b))
|
||||||
return 0;
|
return 0;
|
||||||
@ -499,7 +498,7 @@ callinstr(Node **np, NodeList **init, int wr, int skip)
|
|||||||
// that has got a pointer inside. Whether it points to
|
// that has got a pointer inside. Whether it points to
|
||||||
// the heap or not is impossible to know at compile time
|
// the heap or not is impossible to know at compile time
|
||||||
if((class&PHEAP) || class == PPARAMREF || class == PEXTERN
|
if((class&PHEAP) || class == PPARAMREF || class == PEXTERN
|
||||||
|| b->op == OINDEX || b->op == ODOTPTR || b->op == OIND || b->op == OXDOT) {
|
|| b->op == OINDEX || b->op == ODOTPTR || b->op == OIND) {
|
||||||
hascalls = 0;
|
hascalls = 0;
|
||||||
foreach(n, hascallspred, &hascalls);
|
foreach(n, hascallspred, &hascalls);
|
||||||
if(hascalls) {
|
if(hascalls) {
|
||||||
@ -568,25 +567,6 @@ uintptraddr(Node *n)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// basenod returns the simplest child node of n pointing to the same
|
|
||||||
// memory area.
|
|
||||||
static Node*
|
|
||||||
basenod(Node *n)
|
|
||||||
{
|
|
||||||
for(;;) {
|
|
||||||
if(n->op == ODOT || n->op == OXDOT || n->op == OCONVNOP || n->op == OCONV || n->op == OPAREN) {
|
|
||||||
n = n->left;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(n->op == OINDEX && isfixedarray(n->type)) {
|
|
||||||
n = n->left;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Node*
|
static Node*
|
||||||
detachexpr(Node *n, NodeList **init)
|
detachexpr(Node *n, NodeList **init)
|
||||||
{
|
{
|
||||||
|
@ -1963,8 +1963,7 @@ isstack(Node *n)
|
|||||||
{
|
{
|
||||||
Node *defn;
|
Node *defn;
|
||||||
|
|
||||||
while(n->op == ODOT || n->op == OPAREN || n->op == OCONVNOP || n->op == OINDEX && isfixedarray(n->left->type))
|
n = outervalue(n);
|
||||||
n = n->left;
|
|
||||||
|
|
||||||
// If n is *autotmp and autotmp = &foo, replace n with foo.
|
// If n is *autotmp and autotmp = &foo, replace n with foo.
|
||||||
// We introduce such temps when initializing struct literals.
|
// We introduce such temps when initializing struct literals.
|
||||||
@ -1995,8 +1994,7 @@ isstack(Node *n)
|
|||||||
static int
|
static int
|
||||||
isglobal(Node *n)
|
isglobal(Node *n)
|
||||||
{
|
{
|
||||||
while(n->op == ODOT || n->op == OPAREN || n->op == OCONVNOP || n->op == OINDEX && isfixedarray(n->left->type))
|
n = outervalue(n);
|
||||||
n = n->left;
|
|
||||||
|
|
||||||
switch(n->op) {
|
switch(n->op) {
|
||||||
case ONAME:
|
case ONAME:
|
||||||
@ -2355,7 +2353,9 @@ Node*
|
|||||||
outervalue(Node *n)
|
outervalue(Node *n)
|
||||||
{
|
{
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(n->op == ODOT || n->op == OPAREN) {
|
if(n->op == OXDOT)
|
||||||
|
fatal("OXDOT in walk");
|
||||||
|
if(n->op == ODOT || n->op == OPAREN || n->op == OCONVNOP) {
|
||||||
n = n->left;
|
n = n->left;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user