72
|
1 module dmd.UnrolledLoopStatement;
|
|
2
|
114
|
3 import dmd.common;
|
72
|
4 import dmd.Expression;
|
|
5 import dmd.Statement;
|
|
6 import dmd.InterState;
|
|
7 import dmd.ArrayTypes;
|
|
8 import dmd.OutBuffer;
|
|
9 import dmd.Loc;
|
|
10 import dmd.Scope;
|
|
11 import dmd.InlineCostState;
|
|
12 import dmd.InlineDoState;
|
|
13 import dmd.IRState;
|
|
14 import dmd.HdrGenState;
|
0
|
15 import dmd.InlineScanState;
|
72
|
16 import dmd.BE;
|
|
17
|
|
18 import dmd.backend.BC;
|
|
19 import dmd.backend.Blockx;
|
|
20 import dmd.backend.block;
|
|
21 import dmd.backend.Util;
|
|
22
|
0
|
23 class UnrolledLoopStatement : Statement
|
|
24 {
|
|
25 Statements statements;
|
|
26
|
56
|
27 this(Loc loc, Statements s)
|
0
|
28 {
|
72
|
29 super(loc);
|
56
|
30 statements = s;
|
0
|
31 }
|
|
32
|
72
|
33 override Statement syntaxCopy()
|
0
|
34 {
|
|
35 assert(false);
|
|
36 }
|
|
37
|
72
|
38 override Statement semantic(Scope sc)
|
0
|
39 {
|
72
|
40 //printf("UnrolledLoopStatement.semantic(this = %p, sc = %p)\n", this, sc);
|
|
41
|
|
42 sc.noctor++;
|
|
43 Scope scd = sc.push();
|
|
44 scd.sbreak = this;
|
|
45 scd.scontinue = this;
|
|
46
|
|
47 for (size_t i = 0; i < statements.dim; i++)
|
|
48 {
|
|
49 Statement s = cast(Statement) statements.data[i];
|
|
50 if (s)
|
|
51 {
|
|
52 s = s.semantic(scd);
|
|
53 statements.data[i] = cast(void*)s;
|
|
54 }
|
|
55 }
|
|
56
|
|
57 scd.pop();
|
|
58 sc.noctor--;
|
56
|
59 return this;
|
0
|
60 }
|
|
61
|
72
|
62 override bool hasBreak()
|
0
|
63 {
|
|
64 assert(false);
|
|
65 }
|
|
66
|
72
|
67 override bool hasContinue()
|
0
|
68 {
|
|
69 assert(false);
|
|
70 }
|
|
71
|
72
|
72 override bool usesEH()
|
0
|
73 {
|
|
74 assert(false);
|
|
75 }
|
|
76
|
72
|
77 override BE blockExit()
|
0
|
78 {
|
72
|
79 BE result = BEfallthru;
|
|
80 for (size_t i = 0; i < statements.dim; i++)
|
|
81 {
|
|
82 Statement s = cast(Statement) statements.data[i];
|
|
83 if (s)
|
|
84 {
|
|
85 int r = s.blockExit();
|
|
86 result |= r & ~(BEbreak | BEcontinue);
|
|
87 }
|
|
88 }
|
56
|
89 return result;
|
0
|
90 }
|
|
91
|
72
|
92 override bool comeFrom()
|
0
|
93 {
|
|
94 assert(false);
|
|
95 }
|
|
96
|
72
|
97 override Expression interpret(InterState istate)
|
0
|
98 {
|
|
99 assert(false);
|
|
100 }
|
|
101
|
72
|
102 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
0
|
103 {
|
|
104 assert(false);
|
|
105 }
|
|
106
|
72
|
107 override int inlineCost(InlineCostState* ics)
|
0
|
108 {
|
|
109 assert(false);
|
|
110 }
|
|
111
|
72
|
112 override Expression doInline(InlineDoState ids)
|
0
|
113 {
|
|
114 assert(false);
|
|
115 }
|
|
116
|
72
|
117 override Statement inlineScan(InlineScanState* iss)
|
0
|
118 {
|
|
119 assert(false);
|
|
120 }
|
|
121
|
72
|
122 override void toIR(IRState* irs)
|
0
|
123 {
|
72
|
124 Blockx* blx = irs.blx;
|
|
125
|
|
126 IRState mystate = IRState(irs, this);
|
|
127 mystate.breakBlock = block_calloc(blx);
|
|
128
|
|
129 block* bpre = blx.curblock;
|
|
130 block_next(blx, BCgoto, null);
|
|
131
|
|
132 block* bdo = blx.curblock;
|
|
133 list_append(&bpre.Bsucc, bdo);
|
|
134
|
|
135 block* bdox;
|
|
136
|
|
137 size_t dim = statements.dim;
|
|
138 for (size_t i = 0 ; i < dim ; i++)
|
|
139 {
|
|
140 Statement s = cast(Statement)statements.data[i];
|
|
141 if (s !is null)
|
|
142 {
|
|
143 mystate.contBlock = block_calloc(blx);
|
|
144
|
|
145 s.toIR(&mystate);
|
|
146
|
|
147 bdox = blx.curblock;
|
|
148 block_next(blx, BCgoto, mystate.contBlock);
|
|
149 list_append(&bdox.Bsucc, mystate.contBlock);
|
|
150 }
|
|
151 }
|
|
152
|
|
153 bdox = blx.curblock;
|
|
154 block_next(blx, BCgoto, mystate.breakBlock);
|
67
|
155 list_append(&bdox.Bsucc, mystate.breakBlock);
|
0
|
156 }
|
|
157 }
|
|
158
|