LEFT | RIGHT |
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 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 | 1434 |
1435 if(w == 0) { | 1435 if(w == 0) { |
1436 // evaluate side effects only. | 1436 // evaluate side effects only. |
1437 regalloc(&dst, types[tptr], N); | 1437 regalloc(&dst, types[tptr], N); |
1438 agen(res, &dst); | 1438 agen(res, &dst); |
1439 agen(n, &dst); | 1439 agen(n, &dst); |
1440 regfree(&dst); | 1440 regfree(&dst); |
1441 return; | 1441 return; |
1442 } | 1442 } |
1443 | 1443 |
1444 // Record site of definition of ns for liveness analysis. | |
1445 if(res->op == ONAME && res->class != PEXTERN) | |
1446 gvardef(res); | |
1447 ········ | |
1448 // If copying .args, that's all the results, so record definition sites | 1444 // If copying .args, that's all the results, so record definition sites |
1449 // for them for the liveness analysis. | 1445 // for them for the liveness analysis. |
1450 if(res->op == ONAME && strcmp(res->sym->name, ".args") == 0) | 1446 if(res->op == ONAME && strcmp(res->sym->name, ".args") == 0) |
1451 for(l = curfn->dcl; l != nil; l = l->next) | 1447 for(l = curfn->dcl; l != nil; l = l->next) |
1452 if(l->n->class == PPARAMOUT) | 1448 if(l->n->class == PPARAMOUT) |
1453 gvardef(l->n); | 1449 gvardef(l->n); |
1454 | 1450 |
1455 // Avoid taking the address for simple enough types. | 1451 // Avoid taking the address for simple enough types. |
1456 if(componentgen(n, res)) | 1452 if(componentgen(n, res)) |
1457 return; | 1453 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 // if we are copying forward on the stack and | 1492 // if we are copying forward on the stack and |
1497 // the src and dst overlap, then reverse direction | 1493 // the src and dst overlap, then reverse direction |
1498 dir = align; | 1494 dir = align; |
1499 if(osrc < odst && odst < osrc+w) | 1495 if(osrc < odst && odst < osrc+w) |
1500 dir = -dir; | 1496 dir = -dir; |
1501 | 1497 |
1502 if(n->ullman >= res->ullman) { | 1498 if(n->ullman >= res->ullman) { |
1503 agenr(n, &dst, res); // temporarily use dst | 1499 agenr(n, &dst, res); // temporarily use dst |
1504 regalloc(&src, types[tptr], N); | 1500 regalloc(&src, types[tptr], N); |
1505 gins(AMOVW, &dst, &src); | 1501 gins(AMOVW, &dst, &src); |
| 1502 if(res->op == ONAME) |
| 1503 gvardef(res); |
1506 agen(res, &dst); | 1504 agen(res, &dst); |
1507 } else { | 1505 } else { |
| 1506 if(res->op == ONAME) |
| 1507 gvardef(res); |
1508 agenr(res, &dst, res); | 1508 agenr(res, &dst, res); |
1509 agenr(n, &src, N); | 1509 agenr(n, &src, N); |
1510 } | 1510 } |
1511 | 1511 |
1512 regalloc(&tmp, types[TUINT32], N); | 1512 regalloc(&tmp, types[TUINT32], N); |
1513 | 1513 |
1514 // set up end marker | 1514 // set up end marker |
1515 memset(&nend, 0, sizeof nend); | 1515 memset(&nend, 0, sizeof nend); |
1516 if(c >= 4) { | 1516 if(c >= 4) { |
1517 regalloc(&nend, types[TUINT32], N); | 1517 regalloc(&nend, types[TUINT32], N); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 } else { | 1632 } else { |
1633 // When zeroing, prepare a register containing zero. | 1633 // When zeroing, prepare a register containing zero. |
1634 nodconst(&tmp, nl->type, 0); | 1634 nodconst(&tmp, nl->type, 0); |
1635 regalloc(&nodr, types[TUINT], N); | 1635 regalloc(&nodr, types[TUINT], N); |
1636 gmove(&tmp, &nodr); | 1636 gmove(&tmp, &nodr); |
1637 freer = 1; | 1637 freer = 1; |
1638 } | 1638 } |
1639 | 1639 |
1640 switch(nl->type->etype) { | 1640 switch(nl->type->etype) { |
1641 case TARRAY: | 1641 case TARRAY: |
| 1642 if(nl->op == ONAME) |
| 1643 gvardef(nl); |
1642 nodl.xoffset += Array_array; | 1644 nodl.xoffset += Array_array; |
1643 nodl.type = ptrto(nl->type->type); | 1645 nodl.type = ptrto(nl->type->type); |
1644 | 1646 |
1645 if(nr != N) { | 1647 if(nr != N) { |
1646 nodr.xoffset += Array_array; | 1648 nodr.xoffset += Array_array; |
1647 nodr.type = nodl.type; | 1649 nodr.type = nodl.type; |
1648 } | 1650 } |
1649 gmove(&nodr, &nodl); | 1651 gmove(&nodr, &nodl); |
1650 | 1652 |
1651 nodl.xoffset += Array_nel-Array_array; | 1653 nodl.xoffset += Array_nel-Array_array; |
(...skipping 10 matching lines...) Expand all Loading... |
1662 | 1664 |
1663 if(nr != N) { | 1665 if(nr != N) { |
1664 nodr.xoffset += Array_cap-Array_nel; | 1666 nodr.xoffset += Array_cap-Array_nel; |
1665 nodr.type = nodl.type; | 1667 nodr.type = nodl.type; |
1666 } | 1668 } |
1667 gmove(&nodr, &nodl); | 1669 gmove(&nodr, &nodl); |
1668 | 1670 |
1669 goto yes; | 1671 goto yes; |
1670 | 1672 |
1671 case TSTRING: | 1673 case TSTRING: |
| 1674 if(nl->op == ONAME) |
| 1675 gvardef(nl); |
1672 nodl.xoffset += Array_array; | 1676 nodl.xoffset += Array_array; |
1673 nodl.type = ptrto(types[TUINT8]); | 1677 nodl.type = ptrto(types[TUINT8]); |
1674 | 1678 |
1675 if(nr != N) { | 1679 if(nr != N) { |
1676 nodr.xoffset += Array_array; | 1680 nodr.xoffset += Array_array; |
1677 nodr.type = nodl.type; | 1681 nodr.type = nodl.type; |
1678 } | 1682 } |
1679 gmove(&nodr, &nodl); | 1683 gmove(&nodr, &nodl); |
1680 | 1684 |
1681 nodl.xoffset += Array_nel-Array_array; | 1685 nodl.xoffset += Array_nel-Array_array; |
1682 nodl.type = types[simtype[TUINT]]; | 1686 nodl.type = types[simtype[TUINT]]; |
1683 | 1687 |
1684 if(nr != N) { | 1688 if(nr != N) { |
1685 nodr.xoffset += Array_nel-Array_array; | 1689 nodr.xoffset += Array_nel-Array_array; |
1686 nodr.type = nodl.type; | 1690 nodr.type = nodl.type; |
1687 } | 1691 } |
1688 gmove(&nodr, &nodl); | 1692 gmove(&nodr, &nodl); |
1689 | 1693 |
1690 goto yes; | 1694 goto yes; |
1691 | 1695 |
1692 case TINTER: | 1696 case TINTER: |
| 1697 if(nl->op == ONAME) |
| 1698 gvardef(nl); |
1693 nodl.xoffset += Array_array; | 1699 nodl.xoffset += Array_array; |
1694 nodl.type = ptrto(types[TUINT8]); | 1700 nodl.type = ptrto(types[TUINT8]); |
1695 | 1701 |
1696 if(nr != N) { | 1702 if(nr != N) { |
1697 nodr.xoffset += Array_array; | 1703 nodr.xoffset += Array_array; |
1698 nodr.type = nodl.type; | 1704 nodr.type = nodl.type; |
1699 } | 1705 } |
1700 gmove(&nodr, &nodl); | 1706 gmove(&nodr, &nodl); |
1701 | 1707 |
1702 nodl.xoffset += Array_nel-Array_array; | 1708 nodl.xoffset += Array_nel-Array_array; |
(...skipping 15 matching lines...) Expand all Loading... |
1718 regfree(&nodl); | 1724 regfree(&nodl); |
1719 return 0; | 1725 return 0; |
1720 | 1726 |
1721 yes: | 1727 yes: |
1722 if(freer) | 1728 if(freer) |
1723 regfree(&nodr); | 1729 regfree(&nodr); |
1724 if(freel) | 1730 if(freel) |
1725 regfree(&nodl); | 1731 regfree(&nodl); |
1726 return 1; | 1732 return 1; |
1727 } | 1733 } |
LEFT | RIGHT |