LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include <u.h> | 5 #include <u.h> |
6 #include <libc.h> | 6 #include <libc.h> |
7 #include "gg.h" | 7 #include "gg.h" |
8 | 8 |
9 /* | 9 /* |
10 * generate: | 10 * generate: |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 if(debug['g']) { | 23 if(debug['g']) { |
24 dump("\ncgen-n", n); | 24 dump("\ncgen-n", n); |
25 dump("cgen-res", res); | 25 dump("cgen-res", res); |
26 } | 26 } |
27 if(n == N || n->type == T) | 27 if(n == N || n->type == T) |
28 goto ret; | 28 goto ret; |
29 | 29 |
30 if(res == N || res->type == T) | 30 if(res == N || res->type == T) |
31 fatal("cgen: res nil"); | 31 fatal("cgen: res nil"); |
| 32 |
| 33 switch(n->op) { |
| 34 case OSLICE: |
| 35 case OSLICEARR: |
| 36 case OSLICESTR: |
| 37 if (res->op != ONAME || !res->addable) { |
| 38 tempname(&n1, n->type); |
| 39 cgen_slice(n, &n1); |
| 40 cgen(&n1, res); |
| 41 } else |
| 42 cgen_slice(n, res); |
| 43 return; |
| 44 } |
32 | 45 |
33 while(n->op == OCONVNOP) | 46 while(n->op == OCONVNOP) |
34 n = n->left; | 47 n = n->left; |
35 | 48 |
36 if(n->ullman >= UINF) { | 49 if(n->ullman >= UINF) { |
37 if(n->op == OINDREG) | 50 if(n->op == OINDREG) |
38 fatal("cgen: this is going to misscompile"); | 51 fatal("cgen: this is going to misscompile"); |
39 if(res->ullman >= UINF) { | 52 if(res->ullman >= UINF) { |
40 tempname(&n1, n->type); | 53 tempname(&n1, n->type); |
41 cgen(n, &n1); | 54 cgen(n, &n1); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 else | 579 else |
567 cgen_call(n, 0); | 580 cgen_call(n, 0); |
568 if(r >= 0) | 581 if(r >= 0) |
569 reg[r]++; | 582 reg[r]++; |
570 cgen_aret(n, res); | 583 cgen_aret(n, res); |
571 break; | 584 break; |
572 | 585 |
573 case OCALLINTER: | 586 case OCALLINTER: |
574 cgen_callinter(n, res, 0); | 587 cgen_callinter(n, res, 0); |
575 cgen_aret(n, res); | 588 cgen_aret(n, res); |
| 589 break; |
| 590 |
| 591 case OSLICE: |
| 592 case OSLICEARR: |
| 593 case OSLICESTR: |
| 594 tempname(&n1, n->type); |
| 595 cgen_slice(n, &n1); |
| 596 agen(&n1, res); |
576 break; | 597 break; |
577 | 598 |
578 case OINDEX: | 599 case OINDEX: |
579 p2 = nil; // to be patched to panicindex. | 600 p2 = nil; // to be patched to panicindex. |
580 w = n->type->width; | 601 w = n->type->width; |
581 if(nr->addable) { | 602 if(nr->addable) { |
582 if(!isconst(nr, CTINT)) | 603 if(!isconst(nr, CTINT)) |
583 tempname(&tmp, types[TINT32]); | 604 tempname(&tmp, types[TINT32]); |
584 if(!isconst(nl, CTSTR)) | 605 if(!isconst(nl, CTSTR)) |
585 agenr(nl, &n3, res); | 606 agenr(nl, &n3, res); |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 p->to.type = D_OREG; | 1372 p->to.type = D_OREG; |
1352 p->to.offset = dir; | 1373 p->to.offset = dir; |
1353 p->scond |= C_PBIT; | 1374 p->scond |= C_PBIT; |
1354 } | 1375 } |
1355 } | 1376 } |
1356 | 1377 |
1357 regfree(&dst); | 1378 regfree(&dst); |
1358 regfree(&src); | 1379 regfree(&src); |
1359 regfree(&tmp); | 1380 regfree(&tmp); |
1360 } | 1381 } |
LEFT | RIGHT |