diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-10-04 20:02:58 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-10-04 20:02:58 +0200 |
commit | bfd0cb0db474a2ace38443537aff86382ec10baf (patch) | |
tree | bd37e71c63992d5ee17a12c3d132393106612985 | |
parent | 9e3ef5c777971707ab4ba426bb55d3bb2553ddf9 (diff) |
cc/6c: fix return type of mixed asop expressions, preserve type for moves so fixed<->float conversions work correctly
-rw-r--r-- | sys/src/cmd/6c/txt.c | 19 | ||||
-rw-r--r-- | sys/src/cmd/cc/com.c | 26 |
2 files changed, 20 insertions, 25 deletions
diff --git a/sys/src/cmd/6c/txt.c b/sys/src/cmd/6c/txt.c index 85c4f2a46..5239b5633 100644 --- a/sys/src/cmd/6c/txt.c +++ b/sys/src/cmd/6c/txt.c @@ -677,14 +677,10 @@ gmove(Node *f, Node *t) return; } case TUVLONG: - a = AMOVQ; - goto ld; case TIND: a = AMOVQ; - ld: regalloc(&nod, f, t); - nod.type = t64? types[TVLONG]: types[TINT]; gins(a, f, &nod); gmove(&nod, t); regfree(&nod); @@ -692,19 +688,10 @@ gmove(Node *f, Node *t) case TFLOAT: a = AMOVSS; - goto fld; + goto ld; case TDOUBLE: a = AMOVSD; - fld: - regalloc(&nod, f, t); - if(tt != TDOUBLE && tt != TFLOAT){ /* TO DO: why is this here */ - prtree(f, "odd tree"); - nod.type = t64? types[TVLONG]: types[TINT]; - } - gins(a, f, &nod); - gmove(&nod, t); - regfree(&nod); - return; + goto ld; } /* @@ -1077,7 +1064,7 @@ gmove(Node *f, Node *t) case CASE( TUSHORT,TFLOAT): case CASE( TINT, TFLOAT): case CASE( TLONG, TFLOAT): - case CASE( TVLONG, TFLOAT): + case CASE( TVLONG, TFLOAT): case CASE( TIND, TFLOAT): case CASE( TCHAR, TDOUBLE): diff --git a/sys/src/cmd/cc/com.c b/sys/src/cmd/cc/com.c index c34b7156f..b8a3b5c44 100644 --- a/sys/src/cmd/cc/com.c +++ b/sys/src/cmd/cc/com.c @@ -178,12 +178,15 @@ tcomo(Node *n, int f) arith(n, 0); while(n->left->op == OCAST) n->left = n->left->left; - if(!sametype(t, n->type) && !mixedasop(t, n->type)) { - r = new1(OCAST, n->right, Z); - r->type = t; - n->right = r; + if(!mixedasop(t, n->type)) { + if(!sametype(t, n->type)) { + r = new1(OCAST, n->right, Z); + r->type = t; + n->right = r; + n->type = t; + } + } else n->type = t; - } break; case OASMUL: @@ -205,11 +208,16 @@ tcomo(Node *n, int f) arith(n, 0); while(n->left->op == OCAST) n->left = n->left->left; - if(!sametype(t, n->type) && !mixedasop(t, n->type)) { - r = new1(OCAST, n->right, Z); - r->type = t; - n->right = r; + if(!mixedasop(t, n->type)) { + if(!sametype(t, n->type)) { + r = new1(OCAST, n->right, Z); + r->type = t; + n->right = r; + n->type = t; + } + } else { n->type = t; + break; } if(typeu[n->type->etype]) { if(n->op == OASDIV) |