Mercurial > projects > ldc
annotate dmd/statement.h @ 945:03d7c4aac654
SWITCHED TO LLVM 2.5 !
Applied patch from ticket #129 to compile against latest LLVM. Thanks Frits van Bommel.
Fixed implicit return by asm block at the end of a function on x86-32. Other architectures will produce an error at the moment. Adding support for new targets is fairly simple.
Fixed return calling convention for complex numbers, ST and ST(1) were switched around.
Added some testcases.
I've run a dstress test and there are no regressions. However, the runtime does not seem to compile with symbolic debug information. -O3 -release -inline works well and is what I used for the dstress run. Tango does not compile, a small workaround is needed in tango.io.digest.Digest.Digest.hexDigest. See ticket #206 .
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 08 Feb 2009 05:26:54 +0100 |
parents | 545f54041d91 |
children | b30fe7e1dbb9 |
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 | |
164 // Avoid dynamic_cast | |
165 virtual DeclarationStatement *isDeclarationStatement() { return NULL; } | |
166 virtual CompoundStatement *isCompoundStatement() { return NULL; } | |
167 virtual ReturnStatement *isReturnStatement() { return NULL; } | |
168 virtual IfStatement *isIfStatement() { return NULL; } | |
169 virtual CaseStatement* isCaseStatement() { return NULL; } | |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
170 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
171 // LDC |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
172 virtual void toNakedIR(IRState *irs); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
173 virtual AsmBlockStatement* endsWithAsm(); |
336 | 174 }; |
175 | |
176 struct ExpStatement : Statement | |
177 { | |
178 Expression *exp; | |
179 | |
180 ExpStatement(Loc loc, Expression *exp); | |
181 Statement *syntaxCopy(); | |
182 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
183 Statement *semantic(Scope *sc); | |
184 Expression *interpret(InterState *istate); | |
185 int blockExit(); | |
186 | |
187 int inlineCost(InlineCostState *ics); | |
188 Expression *doInline(InlineDoState *ids); | |
189 Statement *inlineScan(InlineScanState *iss); | |
190 | |
191 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
|
192 |
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 // 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
|
194 void toNakedIR(IRState *irs); |
336 | 195 }; |
196 | |
197 struct CompileStatement : Statement | |
198 { | |
199 Expression *exp; | |
200 | |
201 CompileStatement(Loc loc, Expression *exp); | |
202 Statement *syntaxCopy(); | |
203 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
204 Statements *flatten(Scope *sc); | |
205 Statement *semantic(Scope *sc); | |
206 }; | |
207 | |
208 struct DeclarationStatement : ExpStatement | |
209 { | |
210 // Doing declarations as an expression, rather than a statement, | |
211 // makes inlining functions much easier. | |
212 | |
213 DeclarationStatement(Loc loc, Dsymbol *s); | |
214 DeclarationStatement(Loc loc, Expression *exp); | |
215 Statement *syntaxCopy(); | |
216 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
217 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
218 | |
219 DeclarationStatement *isDeclarationStatement() { return this; } | |
220 }; | |
221 | |
222 struct CompoundStatement : Statement | |
223 { | |
224 Statements *statements; | |
225 | |
226 CompoundStatement(Loc loc, Statements *s); | |
227 CompoundStatement(Loc loc, Statement *s1, Statement *s2); | |
228 virtual Statement *syntaxCopy(); | |
229 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
230 virtual Statement *semantic(Scope *sc); | |
231 int usesEH(); | |
232 int blockExit(); | |
233 int comeFrom(); | |
234 virtual Statements *flatten(Scope *sc); | |
235 ReturnStatement *isReturnStatement(); | |
236 Expression *interpret(InterState *istate); | |
237 | |
238 int inlineCost(InlineCostState *ics); | |
239 Expression *doInline(InlineDoState *ids); | |
240 Statement *inlineScan(InlineScanState *iss); | |
241 | |
242 virtual void toIR(IRState *irs); | |
243 | |
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
|
244 // 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
|
245 virtual void toNakedIR(IRState *irs); |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
246 virtual AsmBlockStatement* endsWithAsm(); |
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
|
247 |
336 | 248 virtual CompoundStatement *isCompoundStatement() { return this; } |
249 }; | |
250 | |
251 /* The purpose of this is so that continue will go to the next | |
252 * of the statements, and break will go to the end of the statements. | |
253 */ | |
254 struct UnrolledLoopStatement : Statement | |
255 { | |
256 Statements *statements; | |
257 EnclosingHandler* enclosinghandler; | |
258 | |
259 UnrolledLoopStatement(Loc loc, Statements *statements); | |
260 Statement *syntaxCopy(); | |
261 Statement *semantic(Scope *sc); | |
262 int hasBreak(); | |
263 int hasContinue(); | |
264 int usesEH(); | |
265 int blockExit(); | |
266 int comeFrom(); | |
267 Expression *interpret(InterState *istate); | |
268 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
269 | |
270 int inlineCost(InlineCostState *ics); | |
271 Expression *doInline(InlineDoState *ids); | |
272 Statement *inlineScan(InlineScanState *iss); | |
273 | |
274 void toIR(IRState *irs); | |
275 }; | |
276 | |
277 struct ScopeStatement : Statement | |
278 { | |
279 Statement *statement; | |
280 | |
281 ScopeStatement(Loc loc, Statement *s); | |
282 Statement *syntaxCopy(); | |
283 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
284 ScopeStatement *isScopeStatement() { return this; } | |
285 Statement *semantic(Scope *sc); | |
286 int hasBreak(); | |
287 int hasContinue(); | |
288 int usesEH(); | |
289 int blockExit(); | |
290 int comeFrom(); | |
291 Expression *interpret(InterState *istate); | |
292 | |
293 Statement *inlineScan(InlineScanState *iss); | |
294 | |
295 void toIR(IRState *irs); | |
296 }; | |
297 | |
298 struct WhileStatement : Statement | |
299 { | |
300 Expression *condition; | |
301 Statement *body; | |
302 EnclosingHandler* enclosinghandler; | |
303 | |
304 WhileStatement(Loc loc, Expression *c, Statement *b); | |
305 Statement *syntaxCopy(); | |
306 Statement *semantic(Scope *sc); | |
307 int hasBreak(); | |
308 int hasContinue(); | |
309 int usesEH(); | |
310 int blockExit(); | |
311 int comeFrom(); | |
312 Expression *interpret(InterState *istate); | |
313 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
314 | |
315 Statement *inlineScan(InlineScanState *iss); | |
316 | |
317 void toIR(IRState *irs); | |
318 }; | |
319 | |
320 struct DoStatement : Statement | |
321 { | |
322 Statement *body; | |
323 Expression *condition; | |
324 EnclosingHandler* enclosinghandler; | |
325 | |
326 DoStatement(Loc loc, Statement *b, Expression *c); | |
327 Statement *syntaxCopy(); | |
328 Statement *semantic(Scope *sc); | |
329 int hasBreak(); | |
330 int hasContinue(); | |
331 int usesEH(); | |
332 int blockExit(); | |
333 int comeFrom(); | |
334 Expression *interpret(InterState *istate); | |
335 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
336 | |
337 Statement *inlineScan(InlineScanState *iss); | |
338 | |
339 void toIR(IRState *irs); | |
340 }; | |
341 | |
342 struct ForStatement : Statement | |
343 { | |
344 Statement *init; | |
345 Expression *condition; | |
346 Expression *increment; | |
347 Statement *body; | |
348 EnclosingHandler* enclosinghandler; | |
349 | |
350 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); | |
351 Statement *syntaxCopy(); | |
352 Statement *semantic(Scope *sc); | |
353 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
354 int hasBreak(); | |
355 int hasContinue(); | |
356 int usesEH(); | |
357 int blockExit(); | |
358 int comeFrom(); | |
359 Expression *interpret(InterState *istate); | |
360 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
361 | |
362 Statement *inlineScan(InlineScanState *iss); | |
363 | |
364 void toIR(IRState *irs); | |
365 }; | |
366 | |
367 struct ForeachStatement : Statement | |
368 { | |
369 enum TOK op; // TOKforeach or TOKforeach_reverse | |
370 Arguments *arguments; // array of Argument*'s | |
371 Expression *aggr; | |
372 Statement *body; | |
373 EnclosingHandler* enclosinghandler; | |
374 | |
375 VarDeclaration *key; | |
376 VarDeclaration *value; | |
377 | |
378 FuncDeclaration *func; // function we're lexically in | |
379 | |
380 Array cases; // put breaks, continues, gotos and returns here | |
381 Array gotos; // forward referenced goto's go here | |
382 | |
383 ForeachStatement(Loc loc, enum TOK op, Arguments *arguments, Expression *aggr, Statement *body); | |
384 Statement *syntaxCopy(); | |
385 Statement *semantic(Scope *sc); | |
386 int hasBreak(); | |
387 int hasContinue(); | |
388 int usesEH(); | |
389 int blockExit(); | |
390 int comeFrom(); | |
391 Expression *interpret(InterState *istate); | |
392 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
393 | |
394 Statement *inlineScan(InlineScanState *iss); | |
395 | |
396 void toIR(IRState *irs); | |
397 }; | |
398 | |
399 #if DMDV2 | |
400 struct ForeachRangeStatement : Statement | |
401 { | |
402 enum TOK op; // TOKforeach or TOKforeach_reverse | |
403 Argument *arg; // loop index variable | |
404 Expression *lwr; | |
405 Expression *upr; | |
406 Statement *body; | |
407 | |
408 VarDeclaration *key; | |
409 | |
410 ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg, | |
411 Expression *lwr, Expression *upr, Statement *body); | |
412 Statement *syntaxCopy(); | |
413 Statement *semantic(Scope *sc); | |
414 int hasBreak(); | |
415 int hasContinue(); | |
416 int usesEH(); | |
417 int blockExit(); | |
418 int comeFrom(); | |
419 Expression *interpret(InterState *istate); | |
420 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
421 | |
422 Statement *inlineScan(InlineScanState *iss); | |
423 | |
424 void toIR(IRState *irs); | |
425 }; | |
426 #endif | |
427 | |
428 struct IfStatement : Statement | |
429 { | |
430 Argument *arg; | |
431 Expression *condition; | |
432 Statement *ifbody; | |
433 Statement *elsebody; | |
434 | |
435 VarDeclaration *match; // for MatchExpression results | |
436 | |
437 IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody); | |
438 Statement *syntaxCopy(); | |
439 Statement *semantic(Scope *sc); | |
440 Expression *interpret(InterState *istate); | |
441 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
442 int usesEH(); | |
443 int blockExit(); | |
444 IfStatement *isIfStatement() { return this; } | |
445 | |
446 int inlineCost(InlineCostState *ics); | |
447 Expression *doInline(InlineDoState *ids); | |
448 Statement *inlineScan(InlineScanState *iss); | |
449 | |
450 void toIR(IRState *irs); | |
451 }; | |
452 | |
453 struct ConditionalStatement : Statement | |
454 { | |
455 Condition *condition; | |
456 Statement *ifbody; | |
457 Statement *elsebody; | |
458 | |
459 ConditionalStatement(Loc loc, Condition *condition, Statement *ifbody, Statement *elsebody); | |
460 Statement *syntaxCopy(); | |
461 Statement *semantic(Scope *sc); | |
462 Statements *flatten(Scope *sc); | |
463 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
|
464 int blockExit(); |
336 | 465 |
466 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
467 }; | |
468 | |
469 struct PragmaStatement : Statement | |
470 { | |
471 Identifier *ident; | |
472 Expressions *args; // array of Expression's | |
473 Statement *body; | |
474 | |
475 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); | |
476 Statement *syntaxCopy(); | |
477 Statement *semantic(Scope *sc); | |
478 int usesEH(); | |
479 int blockExit(); | |
480 | |
481 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
482 }; | |
483 | |
484 struct StaticAssertStatement : Statement | |
485 { | |
486 StaticAssert *sa; | |
487 | |
488 StaticAssertStatement(StaticAssert *sa); | |
489 Statement *syntaxCopy(); | |
490 Statement *semantic(Scope *sc); | |
491 | |
492 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
493 }; | |
494 | |
495 struct SwitchStatement : Statement | |
496 { | |
497 Expression *condition; | |
498 Statement *body; | |
499 | |
500 DefaultStatement *sdefault; | |
501 EnclosingHandler* enclosinghandler; | |
502 | |
503 Array gotoCases; // array of unresolved GotoCaseStatement's | |
504 Array *cases; // array of CaseStatement's | |
505 int hasNoDefault; // !=0 if no default statement | |
506 | |
507 SwitchStatement(Loc loc, Expression *c, Statement *b); | |
508 Statement *syntaxCopy(); | |
509 Statement *semantic(Scope *sc); | |
510 int hasBreak(); | |
511 int usesEH(); | |
512 int blockExit(); | |
513 Expression *interpret(InterState *istate); | |
514 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
515 | |
516 Statement *inlineScan(InlineScanState *iss); | |
517 | |
518 void toIR(IRState *irs); | |
519 }; | |
520 | |
521 struct CaseStatement : Statement | |
522 { | |
523 Expression *exp; | |
524 Statement *statement; | |
525 int index; // which case it is (since we sort this) | |
526 block *cblock; // back end: label for the block | |
527 | |
528 CaseStatement(Loc loc, Expression *exp, Statement *s); | |
529 Statement *syntaxCopy(); | |
530 Statement *semantic(Scope *sc); | |
531 int compare(Object *obj); | |
532 int usesEH(); | |
533 int blockExit(); | |
534 int comeFrom(); | |
535 Expression *interpret(InterState *istate); | |
536 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
537 | |
538 Statement *inlineScan(InlineScanState *iss); | |
539 | |
540 void toIR(IRState *irs); | |
541 | |
542 CaseStatement* isCaseStatement() { return this; } | |
543 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
544 // LDC |
336 | 545 llvm::BasicBlock* bodyBB; |
546 llvm::ConstantInt* llvmIdx; | |
547 }; | |
548 | |
549 struct DefaultStatement : Statement | |
550 { | |
551 Statement *statement; | |
552 #if IN_GCC | |
553 block *cblock; // back end: label for the block | |
554 #endif | |
555 | |
556 DefaultStatement(Loc loc, Statement *s); | |
557 Statement *syntaxCopy(); | |
558 Statement *semantic(Scope *sc); | |
559 int usesEH(); | |
560 int blockExit(); | |
561 int comeFrom(); | |
562 Expression *interpret(InterState *istate); | |
563 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
564 | |
565 Statement *inlineScan(InlineScanState *iss); | |
566 | |
567 void toIR(IRState *irs); | |
568 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
569 // LDC |
336 | 570 llvm::BasicBlock* bodyBB; |
571 }; | |
572 | |
573 struct GotoDefaultStatement : Statement | |
574 { | |
575 SwitchStatement *sw; | |
576 EnclosingHandler* enclosinghandler; | |
577 | |
578 GotoDefaultStatement(Loc loc); | |
579 Statement *syntaxCopy(); | |
580 Statement *semantic(Scope *sc); | |
581 Expression *interpret(InterState *istate); | |
582 int blockExit(); | |
583 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
584 | |
585 void toIR(IRState *irs); | |
586 }; | |
587 | |
588 struct GotoCaseStatement : Statement | |
589 { | |
590 Expression *exp; // NULL, or which case to goto | |
591 CaseStatement *cs; // case statement it resolves to | |
592 EnclosingHandler* enclosinghandler; | |
593 SwitchStatement *sw; | |
594 | |
595 GotoCaseStatement(Loc loc, Expression *exp); | |
596 Statement *syntaxCopy(); | |
597 Statement *semantic(Scope *sc); | |
598 Expression *interpret(InterState *istate); | |
599 int blockExit(); | |
600 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
601 | |
602 void toIR(IRState *irs); | |
603 }; | |
604 | |
605 struct SwitchErrorStatement : Statement | |
606 { | |
607 SwitchErrorStatement(Loc loc); | |
608 int blockExit(); | |
609 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
610 | |
611 void toIR(IRState *irs); | |
612 }; | |
613 | |
614 struct ReturnStatement : Statement | |
615 { | |
616 Expression *exp; | |
617 EnclosingHandler* enclosinghandler; | |
618 | |
619 ReturnStatement(Loc loc, Expression *exp); | |
620 Statement *syntaxCopy(); | |
621 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
622 Statement *semantic(Scope *sc); | |
623 int blockExit(); | |
624 Expression *interpret(InterState *istate); | |
625 | |
626 int inlineCost(InlineCostState *ics); | |
627 Expression *doInline(InlineDoState *ids); | |
628 Statement *inlineScan(InlineScanState *iss); | |
629 | |
630 void toIR(IRState *irs); | |
631 | |
632 ReturnStatement *isReturnStatement() { return this; } | |
633 }; | |
634 | |
635 struct BreakStatement : Statement | |
636 { | |
637 Identifier *ident; | |
638 EnclosingHandler* enclosinghandler; | |
639 | |
640 BreakStatement(Loc loc, Identifier *ident); | |
641 Statement *syntaxCopy(); | |
642 Statement *semantic(Scope *sc); | |
643 Expression *interpret(InterState *istate); | |
644 int blockExit(); | |
645 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
646 | |
647 void toIR(IRState *irs); | |
648 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
649 // LDC: only set if ident is set: label statement to jump to |
336 | 650 LabelStatement *target; |
651 }; | |
652 | |
653 struct ContinueStatement : Statement | |
654 { | |
655 Identifier *ident; | |
656 EnclosingHandler* enclosinghandler; | |
657 | |
658 ContinueStatement(Loc loc, Identifier *ident); | |
659 Statement *syntaxCopy(); | |
660 Statement *semantic(Scope *sc); | |
661 Expression *interpret(InterState *istate); | |
662 int blockExit(); | |
663 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
664 | |
665 void toIR(IRState *irs); | |
666 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
667 // LDC: only set if ident is set: label statement to jump to |
336 | 668 LabelStatement *target; |
669 }; | |
670 | |
671 struct SynchronizedStatement : Statement | |
672 { | |
673 Expression *exp; | |
674 Statement *body; | |
675 EnclosingHandler* enclosinghandler; | |
676 | |
677 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); | |
678 Statement *syntaxCopy(); | |
679 Statement *semantic(Scope *sc); | |
680 int hasBreak(); | |
681 int hasContinue(); | |
682 int usesEH(); | |
683 int blockExit(); | |
684 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
685 | |
686 Statement *inlineScan(InlineScanState *iss); | |
687 | |
688 // Back end | |
689 elem *esync; | |
690 SynchronizedStatement(Loc loc, elem *esync, Statement *body); | |
691 void toIR(IRState *irs); | |
692 llvm::Value* llsync; | |
693 }; | |
694 | |
695 struct WithStatement : Statement | |
696 { | |
697 Expression *exp; | |
698 Statement *body; | |
699 VarDeclaration *wthis; | |
700 | |
701 WithStatement(Loc loc, Expression *exp, Statement *body); | |
702 Statement *syntaxCopy(); | |
703 Statement *semantic(Scope *sc); | |
704 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
705 int usesEH(); | |
706 int blockExit(); | |
707 | |
708 Statement *inlineScan(InlineScanState *iss); | |
709 | |
710 void toIR(IRState *irs); | |
711 }; | |
712 | |
713 struct TryCatchStatement : Statement | |
714 { | |
715 Statement *body; | |
716 Array *catches; | |
717 | |
718 TryCatchStatement(Loc loc, Statement *body, Array *catches); | |
719 Statement *syntaxCopy(); | |
720 Statement *semantic(Scope *sc); | |
721 int hasBreak(); | |
722 int usesEH(); | |
723 int blockExit(); | |
724 | |
725 Statement *inlineScan(InlineScanState *iss); | |
726 | |
727 void toIR(IRState *irs); | |
728 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
729 TryCatchStatement *isTryCatchStatement() { return this; } | |
730 }; | |
731 | |
732 struct Catch : Object | |
733 { | |
734 Loc loc; | |
735 Type *type; | |
736 Identifier *ident; | |
737 VarDeclaration *var; | |
738 Statement *handler; | |
739 | |
740 Catch(Loc loc, Type *t, Identifier *id, Statement *handler); | |
741 Catch *syntaxCopy(); | |
742 void semantic(Scope *sc); | |
743 int blockExit(); | |
744 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
745 }; | |
746 | |
747 struct TryFinallyStatement : Statement | |
748 { | |
749 Statement *body; | |
750 Statement *finalbody; | |
751 EnclosingHandler* enclosinghandler; | |
752 | |
753 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | |
754 Statement *syntaxCopy(); | |
755 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
756 Statement *semantic(Scope *sc); | |
757 int hasBreak(); | |
758 int hasContinue(); | |
759 int usesEH(); | |
760 int blockExit(); | |
761 | |
762 Statement *inlineScan(InlineScanState *iss); | |
763 | |
764 void toIR(IRState *irs); | |
765 }; | |
766 | |
767 struct OnScopeStatement : Statement | |
768 { | |
769 TOK tok; | |
770 Statement *statement; | |
771 | |
772 OnScopeStatement(Loc loc, TOK tok, Statement *statement); | |
773 Statement *syntaxCopy(); | |
774 int blockExit(); | |
775 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
776 Statement *semantic(Scope *sc); | |
777 int usesEH(); | |
778 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
779 | |
780 void toIR(IRState *irs); | |
781 }; | |
782 | |
783 struct ThrowStatement : Statement | |
784 { | |
785 Expression *exp; | |
786 | |
787 ThrowStatement(Loc loc, Expression *exp); | |
788 Statement *syntaxCopy(); | |
789 Statement *semantic(Scope *sc); | |
790 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
791 int blockExit(); | |
792 | |
793 Statement *inlineScan(InlineScanState *iss); | |
794 | |
795 void toIR(IRState *irs); | |
796 }; | |
797 | |
798 struct VolatileStatement : Statement | |
799 { | |
800 Statement *statement; | |
801 EnclosingHandler* enclosinghandler; | |
802 | |
803 VolatileStatement(Loc loc, Statement *statement); | |
804 Statement *syntaxCopy(); | |
805 Statement *semantic(Scope *sc); | |
806 Statements *flatten(Scope *sc); | |
807 int blockExit(); | |
808 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
809 | |
810 Statement *inlineScan(InlineScanState *iss); | |
811 | |
812 void toIR(IRState *irs); | |
813 }; | |
814 | |
815 struct GotoStatement : Statement | |
816 { | |
817 Identifier *ident; | |
818 LabelDsymbol *label; | |
819 TryFinallyStatement *tf; | |
820 EnclosingHandler* enclosinghandler; | |
821 | |
822 GotoStatement(Loc loc, Identifier *ident); | |
823 Statement *syntaxCopy(); | |
824 Statement *semantic(Scope *sc); | |
825 int blockExit(); | |
826 Expression *interpret(InterState *istate); | |
827 | |
828 void toIR(IRState *irs); | |
829 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
830 GotoStatement *isGotoStatement() { return this; } | |
831 }; | |
832 | |
833 struct LabelStatement : Statement | |
834 { | |
835 Identifier *ident; | |
836 Statement *statement; | |
837 TryFinallyStatement *tf; | |
838 EnclosingHandler* enclosinghandler; | |
839 block *lblock; // back end | |
840 int isReturnLabel; | |
841 | |
842 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | |
843 Statement *syntaxCopy(); | |
844 Statement *semantic(Scope *sc); | |
845 Statements *flatten(Scope *sc); | |
846 int usesEH(); | |
847 int blockExit(); | |
848 int comeFrom(); | |
849 Expression *interpret(InterState *istate); | |
850 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
851 | |
852 Statement *inlineScan(InlineScanState *iss); | |
853 | |
854 void toIR(IRState *irs); | |
855 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
856 // LDC |
336 | 857 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
|
858 void toNakedIR(IRState *irs); |
336 | 859 }; |
860 | |
861 struct LabelDsymbol : Dsymbol | |
862 { | |
863 LabelStatement *statement; | |
864 | |
865 LabelDsymbol(Identifier *ident); | |
866 LabelDsymbol *isLabel(); | |
867 }; | |
868 | |
869 struct AsmStatement : Statement | |
870 { | |
871 Token *tokens; | |
872 code *asmcode; | |
873 unsigned asmalign; // alignment of this statement | |
874 unsigned refparam; // !=0 if function parameter is referenced | |
875 unsigned naked; // !=0 if function is to be naked | |
876 | |
877 AsmStatement(Loc loc, Token *tokens); | |
878 Statement *syntaxCopy(); | |
879 Statement *semantic(Scope *sc); | |
880 int blockExit(); | |
881 int comeFrom(); | |
882 | |
883 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
884 virtual AsmStatement *isAsmStatement() { return this; } | |
885 | |
886 void toIR(IRState *irs); | |
887 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
888 // LDC |
336 | 889 // non-zero if this is a branch, contains the target labels identifier |
890 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
|
891 |
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
|
892 void toNakedIR(IRState *irs); |
336 | 893 }; |
894 | |
895 struct AsmBlockStatement : CompoundStatement | |
896 { | |
897 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
|
898 TryFinallyStatement* tf; |
336 | 899 |
900 AsmBlockStatement(Loc loc, Statements *s); | |
901 Statements *flatten(Scope *sc); | |
902 Statement *syntaxCopy(); | |
903 Statement *semantic(Scope *sc); | |
904 | |
905 CompoundStatement *isCompoundStatement() { return NULL; } | |
906 AsmBlockStatement *isAsmBlockStatement() { return this; } | |
907 | |
908 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
|
909 void toNakedIR(IRState *irs); |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
910 AsmBlockStatement* endsWithAsm(); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
911 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
912 llvm::Value* abiret; |
336 | 913 }; |
914 | |
915 #endif /* DMD_STATEMENT_H */ |