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