diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-10-06 06:20:01 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-10-06 06:20:01 +0200 |
commit | 2d59b15c39dc0412e2722141cb5d48bf72b5665e (patch) | |
tree | 943cfe2d4d976101544339a07096b6666e3d30b7 /sys/src/cmd/vc | |
parent | 99ddc5b0971c3ce0baddd667ea4c34c635c8e5ab (diff) |
5c/6c/8c/vc: import various changes from charles forsyth
- cover more cases that have no side effects
- ensure function has complex FNX
- pull operators out of OFUNC level
- rewrite OSTRUCT lhs to avoid all side-effects, use regalloc() instead of regret()
Diffstat (limited to 'sys/src/cmd/vc')
-rw-r--r-- | sys/src/cmd/vc/cgen.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/src/cmd/vc/cgen.c b/sys/src/cmd/vc/cgen.c index a8d52d25b..e5d4fc349 100644 --- a/sys/src/cmd/vc/cgen.c +++ b/sys/src/cmd/vc/cgen.c @@ -260,6 +260,7 @@ cgen(Node *n, Node *nn) break; case OFUNC: + l = uncomma(l); if(l->complex >= FNX) { if(l->op != OIND) diag(n, "bad function call"); @@ -530,7 +531,7 @@ genasop(int o, Node *l, Node *r, Node *nn) gopcode(o, &nod1, Z, &nod); gmove(&nod, &nod2); if(nn != Z) - gmove(&nod, nn); + gmove(&nod2, nn); regfree(&nod); regfree(&nod1); if(hardleft) @@ -946,12 +947,12 @@ sugen(Node *n, Node *nn, long w) case OSTRUCT: /* - * rewrite so lhs has no fn call + * rewrite so lhs has no side effects */ - if(nn != Z && nn->complex >= FNX) { + if(nn != Z && side(nn)) { nod1 = *n; nod1.type = typ(TIND, n->type); - regret(&nod2, &nod1); + regalloc(&nod2, &nod1, Z); lcgen(nn, &nod2); regsalloc(&nod0, &nod1); gopcode(OAS, &nod2, Z, &nod0); @@ -1041,6 +1042,7 @@ sugen(Node *n, Node *nn, long w) } else nn = nn->left; n = new(OFUNC, n->left, new(OLIST, nn, n->right)); + n->complex = FNX; n->type = types[TVOID]; n->left->type = types[TVOID]; cgen(n, Z); |