Mercurial > projects > ldc
annotate dmd/statement.h @ 920:545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Fixed align N; in asm blocks.
Fixed inreg parameter passing on x86 for ref/out params.
Removed support for lazy initialization of function local static variables, I have no idea why I ever implemented this, it's not in the D spec, and DMD doesn't support it :P
Some of the global variable related changes might cause minor regressions, but they should be easily fixable.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 03 Feb 2009 08:54:57 +0100 |
parents | 330f999ade44 |
children | 03d7c4aac654 |
rev | line source |
---|---|
336 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2008 by Digital Mars | |
4 // All Rights Reserved | |
5 // written by Walter Bright | |
6 // http://www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #ifndef DMD_STATEMENT_H | |
12 #define DMD_STATEMENT_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include "root.h" | |
19 | |
20 #include "arraytypes.h" | |
21 #include "dsymbol.h" | |
22 #include "lexer.h" | |
23 | |
24 struct OutBuffer; | |
25 struct Scope; | |
26 struct Expression; | |
27 struct LabelDsymbol; | |
28 struct Identifier; | |
29 struct IfStatement; | |
30 struct DeclarationStatement; | |
31 struct DefaultStatement; | |
32 struct VarDeclaration; | |
33 struct Condition; | |
34 struct Module; | |
35 struct Token; | |
36 struct InlineCostState; | |
37 struct InlineDoState; | |
38 struct InlineScanState; | |
39 struct ReturnStatement; | |
40 struct CompoundStatement; | |
41 struct Argument; | |
42 struct StaticAssert; | |
43 struct AsmStatement; | |
44 struct AsmBlockStatement; | |
45 struct GotoStatement; | |
46 struct ScopeStatement; | |
47 struct TryCatchStatement; | |
48 struct TryFinallyStatement; | |
49 struct HdrGenState; | |
50 struct InterState; | |
51 struct CaseStatement; | |
52 struct LabelStatement; | |
53 struct VolatileStatement; | |
54 struct SynchronizedStatement; | |
55 | |
56 enum TOK; | |
57 | |
58 namespace llvm | |
59 { | |
60 class Value; | |
61 class BasicBlock; | |
62 class ConstantInt; | |
63 } | |
64 | |
65 // Back end | |
66 struct IRState; | |
67 struct Blockx; | |
68 #if IN_LLVM | |
69 struct DValue; | |
70 typedef DValue elem; | |
71 #endif | |
72 | |
73 #if IN_GCC | |
74 union tree_node; typedef union tree_node block; | |
75 //union tree_node; typedef union tree_node elem; | |
76 #else | |
77 struct block; | |
78 //struct elem; | |
79 #endif | |
80 struct code; | |
81 | |
82 /* How a statement exits | |
83 */ | |
84 enum BE | |
85 { | |
86 BEnone = 0, | |
87 BEfallthru = 1, | |
88 BEthrow = 2, | |
89 BEreturn = 4, | |
90 BEgoto = 8, | |
91 BEhalt = 0x10, | |
92 BEbreak = 0x20, | |
93 BEcontinue = 0x40, | |
94 BEany = (BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt), | |
95 }; | |
96 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
97 // LDC this is used for tracking try-finally, synchronized and volatile scopes |
336 | 98 // definitions in gen/llvmhelpers.cpp |
99 struct EnclosingHandler : Object | |
100 { | |
101 virtual void emitCode(IRState* p) = 0; | |
102 virtual EnclosingHandler* getEnclosing() = 0; | |
103 }; | |
104 struct EnclosingTryFinally : EnclosingHandler | |
105 { | |
106 TryFinallyStatement* tf; | |
107 void emitCode(IRState* p); | |
108 EnclosingHandler* getEnclosing(); | |
109 EnclosingTryFinally(TryFinallyStatement* _tf) : tf(_tf) {} | |
110 }; | |
111 struct EnclosingVolatile : EnclosingHandler | |
112 { | |
113 VolatileStatement* v; | |
114 void emitCode(IRState* p); | |
115 EnclosingHandler* getEnclosing(); | |
116 EnclosingVolatile(VolatileStatement* _tf) : v(_tf) {} | |
117 }; | |
118 struct EnclosingSynchro : EnclosingHandler | |
119 { | |
120 SynchronizedStatement* s; | |
121 void emitCode(IRState* p); | |
122 EnclosingHandler* getEnclosing(); | |
123 EnclosingSynchro(SynchronizedStatement* _tf) : s(_tf) {} | |
124 }; | |
125 | |
126 struct Statement : Object | |
127 { | |
128 Loc loc; | |
129 | |
130 Statement(Loc loc); | |
131 virtual Statement *syntaxCopy(); | |
132 | |
133 void print(); | |
134 char *toChars(); | |
135 | |
136 void error(const char *format, ...); | |
137 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
138 virtual TryCatchStatement *isTryCatchStatement() { return NULL; } | |
139 virtual GotoStatement *isGotoStatement() { return NULL; } | |
140 virtual AsmStatement *isAsmStatement() { return NULL; } | |
141 virtual AsmBlockStatement *isAsmBlockStatement() { return NULL; } | |
142 #ifdef _DH | |
143 int incontract; | |
144 #endif | |
145 virtual ScopeStatement *isScopeStatement() { return NULL; } | |
146 virtual Statement *semantic(Scope *sc); | |
147 Statement *semanticScope(Scope *sc, Statement *sbreak, Statement *scontinue); | |
148 virtual int hasBreak(); | |
149 virtual int hasContinue(); | |
150 virtual int usesEH(); | |
151 virtual int blockExit(); | |
152 virtual int comeFrom(); | |
153 virtual void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
154 virtual Statements *flatten(Scope *sc); | |
155 virtual Expression *interpret(InterState *istate); | |
156 | |
157 virtual int inlineCost(InlineCostState *ics); | |
158 virtual Expression *doInline(InlineDoState *ids); | |
159 virtual Statement *inlineScan(InlineScanState *iss); | |
160 | |
161 // Back end | |
162 virtual void toIR(IRState *irs); | |
163 | |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
164 // LDC |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
165 virtual void toNakedIR(IRState *irs); |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
166 |
336 | 167 // Avoid dynamic_cast |
168 virtual DeclarationStatement *isDeclarationStatement() { return NULL; } | |
169 virtual CompoundStatement *isCompoundStatement() { return NULL; } | |
170 virtual ReturnStatement *isReturnStatement() { return NULL; } | |
171 virtual IfStatement *isIfStatement() { return NULL; } | |
172 virtual CaseStatement* isCaseStatement() { return NULL; } | |
173 }; | |
174 | |
175 struct ExpStatement : Statement | |
176 { | |
177 Expression *exp; | |
178 | |
179 ExpStatement(Loc loc, Expression *exp); | |
180 Statement *syntaxCopy(); | |
181 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
182 Statement *semantic(Scope *sc); | |
183 Expression *interpret(InterState *istate); | |
184 int blockExit(); | |
185 | |
186 int inlineCost(InlineCostState *ics); | |
187 Expression *doInline(InlineDoState *ids); | |
188 Statement *inlineScan(InlineScanState *iss); | |
189 | |
190 void toIR(IRState *irs); | |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
191 |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
192 // LDC |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
193 void toNakedIR(IRState *irs); |
336 | 194 }; |
195 | |
196 struct CompileStatement : Statement | |
197 { | |
198 Expression *exp; | |
199 | |
200 CompileStatement(Loc loc, Expression *exp); | |
201 Statement *syntaxCopy(); | |
202 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
203 Statements *flatten(Scope *sc); | |
204 Statement *semantic(Scope *sc); | |
205 }; | |
206 | |
207 struct DeclarationStatement : ExpStatement | |
208 { | |
209 // Doing declarations as an expression, rather than a statement, | |
210 // makes inlining functions much easier. | |
211 | |
212 DeclarationStatement(Loc loc, Dsymbol *s); | |
213 DeclarationStatement(Loc loc, Expression *exp); | |
214 Statement *syntaxCopy(); | |
215 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
216 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
217 | |
218 DeclarationStatement *isDeclarationStatement() { return this; } | |
219 }; | |
220 | |
221 struct CompoundStatement : Statement | |
222 { | |
223 Statements *statements; | |
224 | |
225 CompoundStatement(Loc loc, Statements *s); | |
226 CompoundStatement(Loc loc, Statement *s1, Statement *s2); | |
227 virtual Statement *syntaxCopy(); | |
228 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
229 virtual Statement *semantic(Scope *sc); | |
230 int usesEH(); | |
231 int blockExit(); | |
232 int comeFrom(); | |
233 virtual Statements *flatten(Scope *sc); | |
234 ReturnStatement *isReturnStatement(); | |
235 Expression *interpret(InterState *istate); | |
236 | |
237 int inlineCost(InlineCostState *ics); | |
238 Expression *doInline(InlineDoState *ids); | |
239 Statement *inlineScan(InlineScanState *iss); | |
240 | |
241 virtual void toIR(IRState *irs); | |
242 | |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
243 // LDC |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
244 virtual void toNakedIR(IRState *irs); |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
245 |
336 | 246 virtual CompoundStatement *isCompoundStatement() { return this; } |
247 }; | |
248 | |
249 /* The purpose of this is so that continue will go to the next | |
250 * of the statements, and break will go to the end of the statements. | |
251 */ | |
252 struct UnrolledLoopStatement : Statement | |
253 { | |
254 Statements *statements; | |
255 EnclosingHandler* enclosinghandler; | |
256 | |
257 UnrolledLoopStatement(Loc loc, Statements *statements); | |
258 Statement *syntaxCopy(); | |
259 Statement *semantic(Scope *sc); | |
260 int hasBreak(); | |
261 int hasContinue(); | |
262 int usesEH(); | |
263 int blockExit(); | |
264 int comeFrom(); | |
265 Expression *interpret(InterState *istate); | |
266 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
267 | |
268 int inlineCost(InlineCostState *ics); | |
269 Expression *doInline(InlineDoState *ids); | |
270 Statement *inlineScan(InlineScanState *iss); | |
271 | |
272 void toIR(IRState *irs); | |
273 }; | |
274 | |
275 struct ScopeStatement : Statement | |
276 { | |
277 Statement *statement; | |
278 | |
279 ScopeStatement(Loc loc, Statement *s); | |
280 Statement *syntaxCopy(); | |
281 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
282 ScopeStatement *isScopeStatement() { return this; } | |
283 Statement *semantic(Scope *sc); | |
284 int hasBreak(); | |
285 int hasContinue(); | |
286 int usesEH(); | |
287 int blockExit(); | |
288 int comeFrom(); | |
289 Expression *interpret(InterState *istate); | |
290 | |
291 Statement *inlineScan(InlineScanState *iss); | |
292 | |
293 void toIR(IRState *irs); | |
294 }; | |
295 | |
296 struct WhileStatement : Statement | |
297 { | |
298 Expression *condition; | |
299 Statement *body; | |
300 EnclosingHandler* enclosinghandler; | |
301 | |
302 WhileStatement(Loc loc, Expression *c, Statement *b); | |
303 Statement *syntaxCopy(); | |
304 Statement *semantic(Scope *sc); | |
305 int hasBreak(); | |
306 int hasContinue(); | |
307 int usesEH(); | |
308 int blockExit(); | |
309 int comeFrom(); | |
310 Expression *interpret(InterState *istate); | |
311 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
312 | |
313 Statement *inlineScan(InlineScanState *iss); | |
314 | |
315 void toIR(IRState *irs); | |
316 }; | |
317 | |
318 struct DoStatement : Statement | |
319 { | |
320 Statement *body; | |
321 Expression *condition; | |
322 EnclosingHandler* enclosinghandler; | |
323 | |
324 DoStatement(Loc loc, Statement *b, Expression *c); | |
325 Statement *syntaxCopy(); | |
326 Statement *semantic(Scope *sc); | |
327 int hasBreak(); | |
328 int hasContinue(); | |
329 int usesEH(); | |
330 int blockExit(); | |
331 int comeFrom(); | |
332 Expression *interpret(InterState *istate); | |
333 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
334 | |
335 Statement *inlineScan(InlineScanState *iss); | |
336 | |
337 void toIR(IRState *irs); | |
338 }; | |
339 | |
340 struct ForStatement : Statement | |
341 { | |
342 Statement *init; | |
343 Expression *condition; | |
344 Expression *increment; | |
345 Statement *body; | |
346 EnclosingHandler* enclosinghandler; | |
347 | |
348 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); | |
349 Statement *syntaxCopy(); | |
350 Statement *semantic(Scope *sc); | |
351 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
352 int hasBreak(); | |
353 int hasContinue(); | |
354 int usesEH(); | |
355 int blockExit(); | |
356 int comeFrom(); | |
357 Expression *interpret(InterState *istate); | |
358 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
359 | |
360 Statement *inlineScan(InlineScanState *iss); | |
361 | |
362 void toIR(IRState *irs); | |
363 }; | |
364 | |
365 struct ForeachStatement : Statement | |
366 { | |
367 enum TOK op; // TOKforeach or TOKforeach_reverse | |
368 Arguments *arguments; // array of Argument*'s | |
369 Expression *aggr; | |
370 Statement *body; | |
371 EnclosingHandler* enclosinghandler; | |
372 | |
373 VarDeclaration *key; | |
374 VarDeclaration *value; | |
375 | |
376 FuncDeclaration *func; // function we're lexically in | |
377 | |
378 Array cases; // put breaks, continues, gotos and returns here | |
379 Array gotos; // forward referenced goto's go here | |
380 | |
381 ForeachStatement(Loc loc, enum TOK op, Arguments *arguments, Expression *aggr, Statement *body); | |
382 Statement *syntaxCopy(); | |
383 Statement *semantic(Scope *sc); | |
384 int hasBreak(); | |
385 int hasContinue(); | |
386 int usesEH(); | |
387 int blockExit(); | |
388 int comeFrom(); | |
389 Expression *interpret(InterState *istate); | |
390 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
391 | |
392 Statement *inlineScan(InlineScanState *iss); | |
393 | |
394 void toIR(IRState *irs); | |
395 }; | |
396 | |
397 #if DMDV2 | |
398 struct ForeachRangeStatement : Statement | |
399 { | |
400 enum TOK op; // TOKforeach or TOKforeach_reverse | |
401 Argument *arg; // loop index variable | |
402 Expression *lwr; | |
403 Expression *upr; | |
404 Statement *body; | |
405 | |
406 VarDeclaration *key; | |
407 | |
408 ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg, | |
409 Expression *lwr, Expression *upr, Statement *body); | |
410 Statement *syntaxCopy(); | |
411 Statement *semantic(Scope *sc); | |
412 int hasBreak(); | |
413 int hasContinue(); | |
414 int usesEH(); | |
415 int blockExit(); | |
416 int comeFrom(); | |
417 Expression *interpret(InterState *istate); | |
418 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
419 | |
420 Statement *inlineScan(InlineScanState *iss); | |
421 | |
422 void toIR(IRState *irs); | |
423 }; | |
424 #endif | |
425 | |
426 struct IfStatement : Statement | |
427 { | |
428 Argument *arg; | |
429 Expression *condition; | |
430 Statement *ifbody; | |
431 Statement *elsebody; | |
432 | |
433 VarDeclaration *match; // for MatchExpression results | |
434 | |
435 IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody); | |
436 Statement *syntaxCopy(); | |
437 Statement *semantic(Scope *sc); | |
438 Expression *interpret(InterState *istate); | |
439 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
440 int usesEH(); | |
441 int blockExit(); | |
442 IfStatement *isIfStatement() { return this; } | |
443 | |
444 int inlineCost(InlineCostState *ics); | |
445 Expression *doInline(InlineDoState *ids); | |
446 Statement *inlineScan(InlineScanState *iss); | |
447 | |
448 void toIR(IRState *irs); | |
449 }; | |
450 | |
451 struct ConditionalStatement : Statement | |
452 { | |
453 Condition *condition; | |
454 Statement *ifbody; | |
455 Statement *elsebody; | |
456 | |
457 ConditionalStatement(Loc loc, Condition *condition, Statement *ifbody, Statement *elsebody); | |
458 Statement *syntaxCopy(); | |
459 Statement *semantic(Scope *sc); | |
460 Statements *flatten(Scope *sc); | |
461 int usesEH(); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
356
diff
changeset
|
462 int blockExit(); |
336 | 463 |
464 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
465 }; | |
466 | |
467 struct PragmaStatement : Statement | |
468 { | |
469 Identifier *ident; | |
470 Expressions *args; // array of Expression's | |
471 Statement *body; | |
472 | |
473 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); | |
474 Statement *syntaxCopy(); | |
475 Statement *semantic(Scope *sc); | |
476 int usesEH(); | |
477 int blockExit(); | |
478 | |
479 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
480 }; | |
481 | |
482 struct StaticAssertStatement : Statement | |
483 { | |
484 StaticAssert *sa; | |
485 | |
486 StaticAssertStatement(StaticAssert *sa); | |
487 Statement *syntaxCopy(); | |
488 Statement *semantic(Scope *sc); | |
489 | |
490 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
491 }; | |
492 | |
493 struct SwitchStatement : Statement | |
494 { | |
495 Expression *condition; | |
496 Statement *body; | |
497 | |
498 DefaultStatement *sdefault; | |
499 EnclosingHandler* enclosinghandler; | |
500 | |
501 Array gotoCases; // array of unresolved GotoCaseStatement's | |
502 Array *cases; // array of CaseStatement's | |
503 int hasNoDefault; // !=0 if no default statement | |
504 | |
505 SwitchStatement(Loc loc, Expression *c, Statement *b); | |
506 Statement *syntaxCopy(); | |
507 Statement *semantic(Scope *sc); | |
508 int hasBreak(); | |
509 int usesEH(); | |
510 int blockExit(); | |
511 Expression *interpret(InterState *istate); | |
512 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
513 | |
514 Statement *inlineScan(InlineScanState *iss); | |
515 | |
516 void toIR(IRState *irs); | |
517 }; | |
518 | |
519 struct CaseStatement : Statement | |
520 { | |
521 Expression *exp; | |
522 Statement *statement; | |
523 int index; // which case it is (since we sort this) | |
524 block *cblock; // back end: label for the block | |
525 | |
526 CaseStatement(Loc loc, Expression *exp, Statement *s); | |
527 Statement *syntaxCopy(); | |
528 Statement *semantic(Scope *sc); | |
529 int compare(Object *obj); | |
530 int usesEH(); | |
531 int blockExit(); | |
532 int comeFrom(); | |
533 Expression *interpret(InterState *istate); | |
534 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
535 | |
536 Statement *inlineScan(InlineScanState *iss); | |
537 | |
538 void toIR(IRState *irs); | |
539 | |
540 CaseStatement* isCaseStatement() { return this; } | |
541 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
542 // LDC |
336 | 543 llvm::BasicBlock* bodyBB; |
544 llvm::ConstantInt* llvmIdx; | |
545 }; | |
546 | |
547 struct DefaultStatement : Statement | |
548 { | |
549 Statement *statement; | |
550 #if IN_GCC | |
551 block *cblock; // back end: label for the block | |
552 #endif | |
553 | |
554 DefaultStatement(Loc loc, Statement *s); | |
555 Statement *syntaxCopy(); | |
556 Statement *semantic(Scope *sc); | |
557 int usesEH(); | |
558 int blockExit(); | |
559 int comeFrom(); | |
560 Expression *interpret(InterState *istate); | |
561 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
562 | |
563 Statement *inlineScan(InlineScanState *iss); | |
564 | |
565 void toIR(IRState *irs); | |
566 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
567 // LDC |
336 | 568 llvm::BasicBlock* bodyBB; |
569 }; | |
570 | |
571 struct GotoDefaultStatement : Statement | |
572 { | |
573 SwitchStatement *sw; | |
574 EnclosingHandler* enclosinghandler; | |
575 | |
576 GotoDefaultStatement(Loc loc); | |
577 Statement *syntaxCopy(); | |
578 Statement *semantic(Scope *sc); | |
579 Expression *interpret(InterState *istate); | |
580 int blockExit(); | |
581 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
582 | |
583 void toIR(IRState *irs); | |
584 }; | |
585 | |
586 struct GotoCaseStatement : Statement | |
587 { | |
588 Expression *exp; // NULL, or which case to goto | |
589 CaseStatement *cs; // case statement it resolves to | |
590 EnclosingHandler* enclosinghandler; | |
591 SwitchStatement *sw; | |
592 | |
593 GotoCaseStatement(Loc loc, Expression *exp); | |
594 Statement *syntaxCopy(); | |
595 Statement *semantic(Scope *sc); | |
596 Expression *interpret(InterState *istate); | |
597 int blockExit(); | |
598 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
599 | |
600 void toIR(IRState *irs); | |
601 }; | |
602 | |
603 struct SwitchErrorStatement : Statement | |
604 { | |
605 SwitchErrorStatement(Loc loc); | |
606 int blockExit(); | |
607 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
608 | |
609 void toIR(IRState *irs); | |
610 }; | |
611 | |
612 struct ReturnStatement : Statement | |
613 { | |
614 Expression *exp; | |
615 EnclosingHandler* enclosinghandler; | |
616 | |
617 ReturnStatement(Loc loc, Expression *exp); | |
618 Statement *syntaxCopy(); | |
619 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
620 Statement *semantic(Scope *sc); | |
621 int blockExit(); | |
622 Expression *interpret(InterState *istate); | |
623 | |
624 int inlineCost(InlineCostState *ics); | |
625 Expression *doInline(InlineDoState *ids); | |
626 Statement *inlineScan(InlineScanState *iss); | |
627 | |
628 void toIR(IRState *irs); | |
629 | |
630 ReturnStatement *isReturnStatement() { return this; } | |
631 }; | |
632 | |
633 struct BreakStatement : Statement | |
634 { | |
635 Identifier *ident; | |
636 EnclosingHandler* enclosinghandler; | |
637 | |
638 BreakStatement(Loc loc, Identifier *ident); | |
639 Statement *syntaxCopy(); | |
640 Statement *semantic(Scope *sc); | |
641 Expression *interpret(InterState *istate); | |
642 int blockExit(); | |
643 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
644 | |
645 void toIR(IRState *irs); | |
646 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
647 // LDC: only set if ident is set: label statement to jump to |
336 | 648 LabelStatement *target; |
649 }; | |
650 | |
651 struct ContinueStatement : Statement | |
652 { | |
653 Identifier *ident; | |
654 EnclosingHandler* enclosinghandler; | |
655 | |
656 ContinueStatement(Loc loc, Identifier *ident); | |
657 Statement *syntaxCopy(); | |
658 Statement *semantic(Scope *sc); | |
659 Expression *interpret(InterState *istate); | |
660 int blockExit(); | |
661 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
662 | |
663 void toIR(IRState *irs); | |
664 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
665 // LDC: only set if ident is set: label statement to jump to |
336 | 666 LabelStatement *target; |
667 }; | |
668 | |
669 struct SynchronizedStatement : Statement | |
670 { | |
671 Expression *exp; | |
672 Statement *body; | |
673 EnclosingHandler* enclosinghandler; | |
674 | |
675 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); | |
676 Statement *syntaxCopy(); | |
677 Statement *semantic(Scope *sc); | |
678 int hasBreak(); | |
679 int hasContinue(); | |
680 int usesEH(); | |
681 int blockExit(); | |
682 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
683 | |
684 Statement *inlineScan(InlineScanState *iss); | |
685 | |
686 // Back end | |
687 elem *esync; | |
688 SynchronizedStatement(Loc loc, elem *esync, Statement *body); | |
689 void toIR(IRState *irs); | |
690 llvm::Value* llsync; | |
691 }; | |
692 | |
693 struct WithStatement : Statement | |
694 { | |
695 Expression *exp; | |
696 Statement *body; | |
697 VarDeclaration *wthis; | |
698 | |
699 WithStatement(Loc loc, Expression *exp, Statement *body); | |
700 Statement *syntaxCopy(); | |
701 Statement *semantic(Scope *sc); | |
702 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
703 int usesEH(); | |
704 int blockExit(); | |
705 | |
706 Statement *inlineScan(InlineScanState *iss); | |
707 | |
708 void toIR(IRState *irs); | |
709 }; | |
710 | |
711 struct TryCatchStatement : Statement | |
712 { | |
713 Statement *body; | |
714 Array *catches; | |
715 | |
716 TryCatchStatement(Loc loc, Statement *body, Array *catches); | |
717 Statement *syntaxCopy(); | |
718 Statement *semantic(Scope *sc); | |
719 int hasBreak(); | |
720 int usesEH(); | |
721 int blockExit(); | |
722 | |
723 Statement *inlineScan(InlineScanState *iss); | |
724 | |
725 void toIR(IRState *irs); | |
726 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
727 TryCatchStatement *isTryCatchStatement() { return this; } | |
728 }; | |
729 | |
730 struct Catch : Object | |
731 { | |
732 Loc loc; | |
733 Type *type; | |
734 Identifier *ident; | |
735 VarDeclaration *var; | |
736 Statement *handler; | |
737 | |
738 Catch(Loc loc, Type *t, Identifier *id, Statement *handler); | |
739 Catch *syntaxCopy(); | |
740 void semantic(Scope *sc); | |
741 int blockExit(); | |
742 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
743 }; | |
744 | |
745 struct TryFinallyStatement : Statement | |
746 { | |
747 Statement *body; | |
748 Statement *finalbody; | |
749 EnclosingHandler* enclosinghandler; | |
750 | |
751 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | |
752 Statement *syntaxCopy(); | |
753 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
754 Statement *semantic(Scope *sc); | |
755 int hasBreak(); | |
756 int hasContinue(); | |
757 int usesEH(); | |
758 int blockExit(); | |
759 | |
760 Statement *inlineScan(InlineScanState *iss); | |
761 | |
762 void toIR(IRState *irs); | |
763 }; | |
764 | |
765 struct OnScopeStatement : Statement | |
766 { | |
767 TOK tok; | |
768 Statement *statement; | |
769 | |
770 OnScopeStatement(Loc loc, TOK tok, Statement *statement); | |
771 Statement *syntaxCopy(); | |
772 int blockExit(); | |
773 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
774 Statement *semantic(Scope *sc); | |
775 int usesEH(); | |
776 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
777 | |
778 void toIR(IRState *irs); | |
779 }; | |
780 | |
781 struct ThrowStatement : Statement | |
782 { | |
783 Expression *exp; | |
784 | |
785 ThrowStatement(Loc loc, Expression *exp); | |
786 Statement *syntaxCopy(); | |
787 Statement *semantic(Scope *sc); | |
788 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
789 int blockExit(); | |
790 | |
791 Statement *inlineScan(InlineScanState *iss); | |
792 | |
793 void toIR(IRState *irs); | |
794 }; | |
795 | |
796 struct VolatileStatement : Statement | |
797 { | |
798 Statement *statement; | |
799 EnclosingHandler* enclosinghandler; | |
800 | |
801 VolatileStatement(Loc loc, Statement *statement); | |
802 Statement *syntaxCopy(); | |
803 Statement *semantic(Scope *sc); | |
804 Statements *flatten(Scope *sc); | |
805 int blockExit(); | |
806 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
807 | |
808 Statement *inlineScan(InlineScanState *iss); | |
809 | |
810 void toIR(IRState *irs); | |
811 }; | |
812 | |
813 struct GotoStatement : Statement | |
814 { | |
815 Identifier *ident; | |
816 LabelDsymbol *label; | |
817 TryFinallyStatement *tf; | |
818 EnclosingHandler* enclosinghandler; | |
819 | |
820 GotoStatement(Loc loc, Identifier *ident); | |
821 Statement *syntaxCopy(); | |
822 Statement *semantic(Scope *sc); | |
823 int blockExit(); | |
824 Expression *interpret(InterState *istate); | |
825 | |
826 void toIR(IRState *irs); | |
827 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
828 GotoStatement *isGotoStatement() { return this; } | |
829 }; | |
830 | |
831 struct LabelStatement : Statement | |
832 { | |
833 Identifier *ident; | |
834 Statement *statement; | |
835 TryFinallyStatement *tf; | |
836 EnclosingHandler* enclosinghandler; | |
837 block *lblock; // back end | |
838 int isReturnLabel; | |
839 | |
840 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | |
841 Statement *syntaxCopy(); | |
842 Statement *semantic(Scope *sc); | |
843 Statements *flatten(Scope *sc); | |
844 int usesEH(); | |
845 int blockExit(); | |
846 int comeFrom(); | |
847 Expression *interpret(InterState *istate); | |
848 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
849 | |
850 Statement *inlineScan(InlineScanState *iss); | |
851 | |
852 void toIR(IRState *irs); | |
853 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
854 // LDC |
336 | 855 bool asmLabel; // for labels inside inline assembler |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
856 void toNakedIR(IRState *irs); |
336 | 857 }; |
858 | |
859 struct LabelDsymbol : Dsymbol | |
860 { | |
861 LabelStatement *statement; | |
862 | |
863 LabelDsymbol(Identifier *ident); | |
864 LabelDsymbol *isLabel(); | |
865 }; | |
866 | |
867 struct AsmStatement : Statement | |
868 { | |
869 Token *tokens; | |
870 code *asmcode; | |
871 unsigned asmalign; // alignment of this statement | |
872 unsigned refparam; // !=0 if function parameter is referenced | |
873 unsigned naked; // !=0 if function is to be naked | |
874 | |
875 AsmStatement(Loc loc, Token *tokens); | |
876 Statement *syntaxCopy(); | |
877 Statement *semantic(Scope *sc); | |
878 int blockExit(); | |
879 int comeFrom(); | |
880 | |
881 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
882 virtual AsmStatement *isAsmStatement() { return this; } | |
883 | |
884 void toIR(IRState *irs); | |
885 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
886 // LDC |
336 | 887 // non-zero if this is a branch, contains the target labels identifier |
888 Identifier* isBranchToLabel; | |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
889 |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
890 void toNakedIR(IRState *irs); |
336 | 891 }; |
892 | |
893 struct AsmBlockStatement : CompoundStatement | |
894 { | |
895 EnclosingHandler* enclosinghandler; | |
356
44daf304421c
[svn r377] The previous check was too strict, it completely disallowed gotos within finally blocks. This reenables them as long as they don't cross a finally boundary.
ChristianK
parents:
353
diff
changeset
|
896 TryFinallyStatement* tf; |
336 | 897 |
898 AsmBlockStatement(Loc loc, Statements *s); | |
899 Statements *flatten(Scope *sc); | |
900 Statement *syntaxCopy(); | |
901 Statement *semantic(Scope *sc); | |
902 | |
903 CompoundStatement *isCompoundStatement() { return NULL; } | |
904 AsmBlockStatement *isAsmBlockStatement() { return this; } | |
905 | |
906 void toIR(IRState *irs); | |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
907 void toNakedIR(IRState *irs); |
336 | 908 }; |
909 | |
910 #endif /* DMD_STATEMENT_H */ |