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 #undef EXTERN | 5 #undef EXTERN |
6 #define EXTERN | 6 #define EXTERN |
7 #include <u.h> | 7 #include <u.h> |
8 #include <libc.h> | 8 #include <libc.h> |
9 #include "gg.h" | 9 #include "gg.h" |
10 #include "opt.h" | 10 #include "opt.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 q->link = p->link;······ | 53 q->link = p->link;······ |
54 p->link = q;···· | 54 p->link = q;···· |
55 return q;······· | 55 return q;······· |
56 } | 56 } |
57 | 57 |
58 // Sweep the prog list to mark any used nodes. | 58 // Sweep the prog list to mark any used nodes. |
59 void | 59 void |
60 markautoused(Prog* p) | 60 markautoused(Prog* p) |
61 { | 61 { |
62 for (; p; p = p->link) { | 62 for (; p; p = p->link) { |
63 » » if (p->as == ATYPE) | 63 » » if (p->as == ATYPE || p->as == AVARDEF) |
64 continue; | 64 continue; |
65 | 65 |
66 » » if (p->from.type == D_AUTO && p->from.node) | 66 » » if (p->from.node) |
67 p->from.node->used = 1; | 67 p->from.node->used = 1; |
68 | 68 |
69 » » if (p->to.type == D_AUTO && p->to.node) | 69 » » if (p->to.node) |
70 p->to.node->used = 1; | 70 p->to.node->used = 1; |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 // Fixup instructions after allocauto (formerly compactframe) has moved all auto
s around. | 74 // Fixup instructions after allocauto (formerly compactframe) has moved all auto
s around. |
75 void | 75 void |
76 fixautoused(Prog *p) | 76 fixautoused(Prog *p) |
77 { | 77 { |
78 Prog **lp; | 78 Prog **lp; |
79 | 79 |
80 for (lp=&p; (p=*lp) != P; ) { | 80 for (lp=&p; (p=*lp) != P; ) { |
81 if (p->as == ATYPE && p->from.node && p->from.type == D_AUTO &&
!p->from.node->used) { | 81 if (p->as == ATYPE && p->from.node && p->from.type == D_AUTO &&
!p->from.node->used) { |
82 *lp = p->link; | 82 *lp = p->link; |
| 83 continue; |
| 84 } |
| 85 if (p->as == AVARDEF && p->to.node && !p->to.node->used) { |
| 86 // Cannot remove VARDEF instruction, because - unlike TY
PE handled above - |
| 87 // VARDEFs are interspersed with other code, and a jump
might be using the |
| 88 // VARDEF as a target. Replace with a no-op instead. A l
ater pass will remove |
| 89 // the no-ops. |
| 90 p->to.type = D_NONE; |
| 91 p->to.node = N; |
| 92 p->as = ANOP; |
83 continue; | 93 continue; |
84 } | 94 } |
85 if (p->from.type == D_AUTO && p->from.node) | 95 if (p->from.type == D_AUTO && p->from.node) |
86 p->from.offset += p->from.node->stkdelta; | 96 p->from.offset += p->from.node->stkdelta; |
87 | 97 |
88 if (p->to.type == D_AUTO && p->to.node) | 98 if (p->to.type == D_AUTO && p->to.node) |
89 p->to.offset += p->to.node->stkdelta; | 99 p->to.offset += p->to.node->stkdelta; |
90 | 100 |
91 lp = &p->link; | 101 lp = &p->link; |
92 } | 102 } |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 void | 1025 void |
1016 clearfat(Node *nl) | 1026 clearfat(Node *nl) |
1017 { | 1027 { |
1018 int64 w, c, q; | 1028 int64 w, c, q; |
1019 Node n1, oldn1, ax, oldax, di, z; | 1029 Node n1, oldn1, ax, oldax, di, z; |
1020 Prog *p; | 1030 Prog *p; |
1021 | 1031 |
1022 /* clear a fat object */ | 1032 /* clear a fat object */ |
1023 if(debug['g']) | 1033 if(debug['g']) |
1024 dump("\nclearfat", nl); | 1034 dump("\nclearfat", nl); |
1025 | |
1026 gvardef(nl); | |
1027 | 1035 |
1028 w = nl->type->width; | 1036 w = nl->type->width; |
1029 // Avoid taking the address for simple enough types. | 1037 // Avoid taking the address for simple enough types. |
1030 if(componentgen(N, nl)) | 1038 if(componentgen(N, nl)) |
1031 return; | 1039 return; |
1032 | 1040 |
1033 c = w % 8; // bytes | 1041 c = w % 8; // bytes |
1034 q = w / 8; // quads | 1042 q = w / 8; // quads |
1035 | 1043 |
1036 savex(D_DI, &n1, &oldn1, N, types[tptr]); | 1044 savex(D_DI, &n1, &oldn1, N, types[tptr]); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 // which will be shorter to encode than plain 0. | 1124 // which will be shorter to encode than plain 0. |
1117 p2->as = AMOVL; | 1125 p2->as = AMOVL; |
1118 p2->from.type = D_AX; | 1126 p2->from.type = D_AX; |
1119 if(regtyp(&p->from)) | 1127 if(regtyp(&p->from)) |
1120 p2->to.type = p->from.type + D_INDIR; | 1128 p2->to.type = p->from.type + D_INDIR; |
1121 else | 1129 else |
1122 p2->to.type = D_INDIR+D_NONE; | 1130 p2->to.type = D_INDIR+D_NONE; |
1123 p2->to.offset = 0; | 1131 p2->to.offset = 0; |
1124 } | 1132 } |
1125 } | 1133 } |
LEFT | RIGHT |