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 12 matching lines...) Expand all Loading... |
23 frame = rnd(maxstksize+maxarg, widthptr); | 23 frame = rnd(maxstksize+maxarg, widthptr); |
24 ptxt->to.offset = frame; | 24 ptxt->to.offset = frame; |
25 maxstksize = 0; | 25 maxstksize = 0; |
26 } | 26 } |
27 | 27 |
28 // Sweep the prog list to mark any used nodes. | 28 // Sweep the prog list to mark any used nodes. |
29 void | 29 void |
30 markautoused(Prog* p) | 30 markautoused(Prog* p) |
31 { | 31 { |
32 for (; p; p = p->link) { | 32 for (; p; p = p->link) { |
33 » » if (p->as == ATYPE) | 33 » » if (p->as == ATYPE || p->as == AVARDEF) |
34 continue; | 34 continue; |
35 | 35 |
36 » » if (p->from.type == D_AUTO && p->from.node) | 36 » » if (p->from.node) |
37 p->from.node->used = 1; | 37 p->from.node->used = 1; |
38 | 38 |
39 » » if (p->to.type == D_AUTO && p->to.node) | 39 » » if (p->to.node) |
40 p->to.node->used = 1; | 40 p->to.node->used = 1; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 // Fixup instructions after allocauto (formerly compactframe) has moved all auto
s around. | 44 // Fixup instructions after allocauto (formerly compactframe) has moved all auto
s around. |
45 void | 45 void |
46 fixautoused(Prog* p) | 46 fixautoused(Prog* p) |
47 { | 47 { |
48 Prog **lp; | 48 Prog **lp; |
49 | 49 |
50 for (lp=&p; (p=*lp) != P; ) { | 50 for (lp=&p; (p=*lp) != P; ) { |
51 if (p->as == ATYPE && p->from.node && p->from.type == D_AUTO &&
!p->from.node->used) { | 51 if (p->as == ATYPE && p->from.node && p->from.type == D_AUTO &&
!p->from.node->used) { |
52 *lp = p->link; | 52 *lp = p->link; |
53 continue; | 53 continue; |
54 } | 54 } |
| 55 if (p->as == AVARDEF && p->to.node && !p->to.node->used) { |
| 56 // Cannot remove VARDEF instruction, because - unlike TY
PE handled above - |
| 57 // VARDEFs are interspersed with other code, and a jump
might be using the |
| 58 // VARDEF as a target. Replace with a no-op instead. A l
ater pass will remove |
| 59 // the no-ops. |
| 60 p->to.type = D_NONE; |
| 61 p->to.node = N; |
| 62 p->as = ANOP; |
| 63 continue; |
| 64 } |
55 | 65 |
56 if (p->from.type == D_AUTO && p->from.node) | 66 if (p->from.type == D_AUTO && p->from.node) |
57 p->from.offset += p->from.node->stkdelta; | 67 p->from.offset += p->from.node->stkdelta; |
58 | 68 |
59 if (p->to.type == D_AUTO && p->to.node) | 69 if (p->to.type == D_AUTO && p->to.node) |
60 p->to.offset += p->to.node->stkdelta; | 70 p->to.offset += p->to.node->stkdelta; |
61 | 71 |
62 lp = &p->link; | 72 lp = &p->link; |
63 } | 73 } |
64 } | 74 } |
65 | 75 |
66 void | 76 void |
67 clearfat(Node *nl) | 77 clearfat(Node *nl) |
68 { | 78 { |
69 uint32 w, c, q; | 79 uint32 w, c, q; |
70 Node n1; | 80 Node n1; |
71 | 81 |
72 /* clear a fat object */ | 82 /* clear a fat object */ |
73 if(debug['g']) | 83 if(debug['g']) |
74 dump("\nclearfat", nl); | 84 dump("\nclearfat", nl); |
75 | |
76 gvardef(nl); | |
77 | 85 |
78 w = nl->type->width; | 86 w = nl->type->width; |
79 // Avoid taking the address for simple enough types. | 87 // Avoid taking the address for simple enough types. |
80 if(componentgen(N, nl)) | 88 if(componentgen(N, nl)) |
81 return; | 89 return; |
82 | 90 |
83 c = w % 4; // bytes | 91 c = w % 4; // bytes |
84 q = w / 4; // quads | 92 q = w / 4; // quads |
85 | 93 |
86 nodreg(&n1, types[tptr], D_DI); | 94 nodreg(&n1, types[tptr], D_DI); |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 // which will be shorter to encode than plain 0. | 1230 // which will be shorter to encode than plain 0. |
1223 p2->as = AMOVL; | 1231 p2->as = AMOVL; |
1224 p2->from.type = D_AX; | 1232 p2->from.type = D_AX; |
1225 if(regtyp(&p->from)) | 1233 if(regtyp(&p->from)) |
1226 p2->to.type = p->from.type + D_INDIR; | 1234 p2->to.type = p->from.type + D_INDIR; |
1227 else | 1235 else |
1228 p2->to.type = D_INDIR+D_NONE; | 1236 p2->to.type = D_INDIR+D_NONE; |
1229 p2->to.offset = 0; | 1237 p2->to.offset = 0; |
1230 } | 1238 } |
1231 } | 1239 } |
LEFT | RIGHT |