Mercurial > projects > ldc
annotate gen/statements.cpp @ 686:363bb6c0cc80
Emit stub debug info for generated functions to work around LLVM bug 2172.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 12 Oct 2008 14:38:55 +0200 |
parents | b411c41a9716 |
children | 0a682c7805d2 |
rev | line source |
---|---|
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1 // Statements: D -> LLVM glue |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
2 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
3 #include <stdio.h> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
4 #include <math.h> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
5 #include <sstream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
6 #include <fstream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
7 #include <iostream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
8 |
40 | 9 #include "gen/llvm.h" |
131 | 10 #include "llvm/InlineAsm.h" |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
11 #include "llvm/Support/CFG.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
12 |
132 | 13 #include "mars.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
14 #include "total.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
15 #include "init.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
16 #include "mtype.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
17 #include "hdrgen.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
18 #include "port.h" |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
652
diff
changeset
|
19 #include "module.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
20 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
21 #include "gen/irstate.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
22 #include "gen/logger.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
23 #include "gen/tollvm.h" |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
234
diff
changeset
|
24 #include "gen/llvmhelpers.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
25 #include "gen/runtime.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
26 #include "gen/arrays.h" |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
27 #include "gen/todebug.h" |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
28 #include "gen/dvalue.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
29 |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
30 #include "ir/irfunction.h" |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
652
diff
changeset
|
31 #include "ir/irmodule.h" |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
32 #include "ir/irlandingpad.h" |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
33 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
34 ////////////////////////////////////////////////////////////////////////////// |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
35 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
36 void CompoundStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
37 { |
132 | 38 Logger::println("CompoundStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
39 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
40 |
34 | 41 for (int i=0; i<statements->dim; i++) |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
42 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
43 Statement* s = (Statement*)statements->data[i]; |
132 | 44 if (s) { |
34 | 45 s->toIR(p); |
46 } | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
47 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
48 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
49 |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
50 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
51 ////////////////////////////////////////////////////////////////////////////// |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
52 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
53 void ReturnStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
54 { |
132 | 55 Logger::println("ReturnStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
56 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
57 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
58 if (exp) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
59 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
234
diff
changeset
|
60 if (p->topfunc()->getReturnType() == LLType::VoidTy) { |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
61 IrFunction* f = p->func(); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
62 assert(f->type->retInPtr); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
63 assert(f->decl->ir.irFunc->retArg); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
64 |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
65 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
66 |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
519
diff
changeset
|
67 DValue* rvar = new DVarValue(f->type->next, f->decl->ir.irFunc->retArg); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
68 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
69 DValue* e = exp->toElem(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
70 |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
71 DtoAssign(loc, rvar, e); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
72 |
309 | 73 DtoEnclosingHandlers(enclosinghandler, NULL); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
74 |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
75 if (global.params.symdebug) DtoDwarfFuncEnd(f->decl); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
76 llvm::ReturnInst::Create(p->scopebb()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
77 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
78 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
79 else { |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
80 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
81 DValue* e = exp->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
82 LLValue* v = e->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
83 delete e; |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
84 |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
85 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
86 Logger::cout() << "return value is '" <<*v << "'\n"; |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
51
diff
changeset
|
87 |
611
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
88 // can happen for classes |
185
89e21eeaf4c4
[svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents:
181
diff
changeset
|
89 if (v->getType() != p->topfunc()->getReturnType()) |
89e21eeaf4c4
[svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents:
181
diff
changeset
|
90 { |
611
83ca663ecc20
Backed out changeset 1b62222581fb
Christian Kamm <kamm incasoftware de>
parents:
610
diff
changeset
|
91 v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp"); |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
92 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
93 Logger::cout() << "return value after cast: " << *v << '\n'; |
185
89e21eeaf4c4
[svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents:
181
diff
changeset
|
94 } |
89e21eeaf4c4
[svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents:
181
diff
changeset
|
95 |
309 | 96 DtoEnclosingHandlers(enclosinghandler, NULL); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
97 |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
98 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
99 llvm::ReturnInst::Create(v, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
100 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
101 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
102 else |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
103 { |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
234
diff
changeset
|
104 assert(p->topfunc()->getReturnType() == LLType::VoidTy); |
309 | 105 DtoEnclosingHandlers(enclosinghandler, NULL); |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
106 |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
107 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
108 llvm::ReturnInst::Create(p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
109 } |
267
c43911baea21
[svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents:
263
diff
changeset
|
110 |
c43911baea21
[svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents:
263
diff
changeset
|
111 // the return terminated this basicblock, start a new one |
c43911baea21
[svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents:
263
diff
changeset
|
112 llvm::BasicBlock* oldend = gIR->scopeend(); |
c43911baea21
[svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents:
263
diff
changeset
|
113 llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterreturn", p->topfunc(), oldend); |
c43911baea21
[svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents:
263
diff
changeset
|
114 p->scope() = IRScope(bb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
115 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
116 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
117 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
118 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
119 void ExpStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
120 { |
132 | 121 Logger::println("ExpStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
122 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
123 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
124 if (global.params.symdebug) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
125 DtoDwarfStopPoint(loc.linnum); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
126 |
137 | 127 if (exp) { |
128 if (global.params.llvmAnnotate) | |
129 DtoAnnotation(exp->toChars()); | |
518
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
130 elem* e; |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
131 // a cast(void) around the expression is allowed, but doesn't require any code |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
132 if(exp->op == TOKcast && exp->type == Type::tvoid) { |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
133 CastExp* cexp = (CastExp*)exp; |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
134 e = cexp->e1->toElem(p); |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
135 } |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
136 else |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
137 e = exp->toElem(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
138 delete e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
139 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
140 /*elem* e = exp->toElem(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
141 p->buf.printf("%s", e->toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
142 delete e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
143 p->buf.writenl();*/ |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
144 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
145 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
146 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
147 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
148 void IfStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
149 { |
132 | 150 Logger::println("IfStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
151 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
152 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
153 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
154 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
155 |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
156 if (match) |
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
157 { |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
158 LLValue* allocainst = DtoAlloca(DtoType(match->type), "._tmp_if_var"); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
159 match->ir.irLocal = new IrLocal(match); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
160 match->ir.irLocal->value = allocainst; |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
161 } |
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
162 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
163 DValue* cond_e = condition->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
164 LLValue* cond_val = cond_e->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
165 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
166 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
167 |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
168 llvm::BasicBlock* ifbb = llvm::BasicBlock::Create("if", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
169 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endif", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
170 llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
171 |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
234
diff
changeset
|
172 if (cond_val->getType() != LLType::Int1Ty) { |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
173 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
174 Logger::cout() << "if conditional: " << *cond_val << '\n'; |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
395
diff
changeset
|
175 cond_val = DtoBoolean(loc, cond_e); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
176 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
177 LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
178 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
179 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
180 gIR->scope() = IRScope(ifbb,elsebb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
181 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
182 // do scoped statements |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
183 if (ifbody) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
184 ifbody->toIR(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
185 if (!gIR->scopereturned()) { |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
186 llvm::BranchInst::Create(endbb,gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
187 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
188 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
189 if (elsebody) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
190 //assert(0); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
191 gIR->scope() = IRScope(elsebb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
192 elsebody->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
193 if (!gIR->scopereturned()) { |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
194 llvm::BranchInst::Create(endbb,gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
195 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
196 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
197 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
198 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
199 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
200 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
201 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
202 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
203 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
204 void ScopeStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
205 { |
132 | 206 Logger::println("ScopeStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
207 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
208 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
209 /*llvm::BasicBlock* oldend = p->scopeend(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
210 |
40 | 211 llvm::BasicBlock* beginbb = 0; |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
212 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
213 // remove useless branches by clearing and reusing the current basicblock |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
214 llvm::BasicBlock* bb = p->scopebb(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
215 if (bb->empty()) { |
40 | 216 beginbb = bb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
217 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
218 else { |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
219 beginbb = llvm::BasicBlock::Create("scope", p->topfunc(), oldend); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
220 if (!p->scopereturned()) |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
221 llvm::BranchInst::Create(beginbb, bb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
222 } |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
223 |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
224 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endscope", p->topfunc(), oldend); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
225 if (beginbb != bb) |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
226 p->scope() = IRScope(beginbb, endbb); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
227 else |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
228 p->scope().end = endbb;*/ |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
229 |
181
ef4108f34db6
[svn r197] Fixed: empty scope statement segfaulted.
lindquist
parents:
175
diff
changeset
|
230 if (statement) |
ef4108f34db6
[svn r197] Fixed: empty scope statement segfaulted.
lindquist
parents:
175
diff
changeset
|
231 statement->toIR(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
232 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
233 /*p->scope().end = oldend; |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
234 Logger::println("Erasing scope endbb"); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
235 endbb->eraseFromParent();*/ |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
236 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
237 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
238 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
239 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
240 void WhileStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
241 { |
132 | 242 Logger::println("WhileStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
243 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
244 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
245 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
246 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
247 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
248 // create while blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
249 llvm::BasicBlock* oldend = gIR->scopeend(); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
250 llvm::BasicBlock* whilebb = llvm::BasicBlock::Create("whilecond", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
251 llvm::BasicBlock* whilebodybb = llvm::BasicBlock::Create("whilebody", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
252 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endwhile", gIR->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
253 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
254 // move into the while block |
40 | 255 p->ir->CreateBr(whilebb); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
256 //llvm::BranchInst::Create(whilebb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
257 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
258 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
259 gIR->scope() = IRScope(whilebb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
260 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
261 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
262 DValue* cond_e = condition->toElem(p); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
395
diff
changeset
|
263 LLValue* cond_val = DtoBoolean(loc, cond_e); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
264 delete cond_e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
265 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
266 // conditional branch |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
267 LLValue* ifbreak = llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
268 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
269 // rewrite scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
270 gIR->scope() = IRScope(whilebodybb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
271 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
272 // while body code |
309 | 273 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,whilebb,endbb)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
274 body->toIR(p); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
275 p->loopbbs.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
276 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
277 // loop |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
278 if (!gIR->scopereturned()) |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
279 llvm::BranchInst::Create(whilebb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
280 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
281 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
282 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
283 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
284 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
285 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
286 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
287 void DoStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
288 { |
132 | 289 Logger::println("DoStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
290 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
291 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
292 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
293 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
294 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
295 // create while blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
296 llvm::BasicBlock* oldend = gIR->scopeend(); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
297 llvm::BasicBlock* dowhilebb = llvm::BasicBlock::Create("dowhile", gIR->topfunc(), oldend); |
517
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
298 llvm::BasicBlock* condbb = llvm::BasicBlock::Create("dowhilecond", gIR->topfunc(), oldend); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
299 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("enddowhile", gIR->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
300 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
301 // move into the while block |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
302 assert(!gIR->scopereturned()); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
303 llvm::BranchInst::Create(dowhilebb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
304 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
305 // replace current scope |
517
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
306 gIR->scope() = IRScope(dowhilebb,condbb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
307 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
308 // do-while body code |
517
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
309 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,condbb,endbb)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
310 body->toIR(p); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
311 p->loopbbs.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
312 |
517
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
313 // branch to condition block |
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
314 llvm::BranchInst::Create(condbb, gIR->scopebb()); |
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
315 gIR->scope() = IRScope(condbb,endbb); |
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
316 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
317 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
318 DValue* cond_e = condition->toElem(p); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
395
diff
changeset
|
319 LLValue* cond_val = DtoBoolean(loc, cond_e); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
320 delete cond_e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
321 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
322 // conditional branch |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
323 LLValue* ifbreak = llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
324 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
325 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
326 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
327 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
328 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
329 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
330 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
331 void ForStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
332 { |
132 | 333 Logger::println("ForStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
334 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
335 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
336 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
337 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
338 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
339 // create for blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
340 llvm::BasicBlock* oldend = gIR->scopeend(); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
341 llvm::BasicBlock* forbb = llvm::BasicBlock::Create("forcond", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
342 llvm::BasicBlock* forbodybb = llvm::BasicBlock::Create("forbody", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
343 llvm::BasicBlock* forincbb = llvm::BasicBlock::Create("forinc", gIR->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
344 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endfor", gIR->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
345 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
346 // init |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
347 if (init != 0) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
348 init->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
349 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
350 // move into the for condition block, ie. start the loop |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
351 assert(!gIR->scopereturned()); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
352 llvm::BranchInst::Create(forbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
353 |
309 | 354 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,forincbb,endbb)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
355 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
356 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
357 gIR->scope() = IRScope(forbb,forbodybb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
358 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
359 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
360 DValue* cond_e = condition->toElem(p); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
395
diff
changeset
|
361 LLValue* cond_val = DtoBoolean(loc, cond_e); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
362 delete cond_e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
363 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
364 // conditional branch |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
365 assert(!gIR->scopereturned()); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
366 llvm::BranchInst::Create(forbodybb, endbb, cond_val, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
367 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
368 // rewrite scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
369 gIR->scope() = IRScope(forbodybb,forincbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
370 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
371 // do for body code |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
372 body->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
373 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
374 // move into the for increment block |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
375 if (!gIR->scopereturned()) |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
376 llvm::BranchInst::Create(forincbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
377 gIR->scope() = IRScope(forincbb, endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
378 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
379 // increment |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
380 if (increment) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
381 DValue* inc = increment->toElem(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
382 delete inc; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
383 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
384 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
385 // loop |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
386 if (!gIR->scopereturned()) |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
387 llvm::BranchInst::Create(forbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
388 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
389 p->loopbbs.pop_back(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
390 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
391 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
392 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
393 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
394 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
395 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
396 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
397 void BreakStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
398 { |
132 | 399 Logger::println("BreakStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
400 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
401 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
402 // don't emit two terminators in a row |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
403 // happens just before DMD generated default statements if the last case terminates |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
404 if (p->scopereturned()) |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
405 return; |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
406 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
407 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
408 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
409 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
410 if (ident != 0) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
411 Logger::println("ident = %s", ident->toChars()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
412 |
309 | 413 DtoEnclosingHandlers(enclosinghandler, target->enclosinghandler); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
414 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
415 // get the loop statement the label refers to |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
416 Statement* targetLoopStatement = target->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
417 ScopeStatement* tmp; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
418 while(tmp = targetLoopStatement->isScopeStatement()) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
419 targetLoopStatement = tmp->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
420 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
421 // find the right break block and jump there |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
422 bool found = false; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
423 IRState::LoopScopeVec::reverse_iterator it; |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
424 for(it = p->loopbbs.rbegin(); it != p->loopbbs.rend(); ++it) { |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
425 if(it->s == targetLoopStatement) { |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
426 llvm::BranchInst::Create(it->end, p->scopebb()); |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
427 found = true; |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
428 break; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
429 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
430 } |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
431 assert(found); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
432 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
433 else { |
309 | 434 DtoEnclosingHandlers(enclosinghandler, p->loopbbs.back().enclosinghandler); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
435 llvm::BranchInst::Create(p->loopbbs.back().end, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
436 } |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
437 |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
438 // the break terminated this basicblock, start a new one |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
439 llvm::BasicBlock* oldend = gIR->scopeend(); |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
440 llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterbreak", p->topfunc(), oldend); |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
441 p->scope() = IRScope(bb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
442 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
443 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
444 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
445 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
446 void ContinueStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
447 { |
132 | 448 Logger::println("ContinueStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
449 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
450 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
451 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
452 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
453 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
454 if (ident != 0) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
455 Logger::println("ident = %s", ident->toChars()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
456 |
309 | 457 DtoEnclosingHandlers(enclosinghandler, target->enclosinghandler); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
458 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
459 // get the loop statement the label refers to |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
460 Statement* targetLoopStatement = target->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
461 ScopeStatement* tmp; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
462 while(tmp = targetLoopStatement->isScopeStatement()) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
463 targetLoopStatement = tmp->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
464 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
465 // find the right continue block and jump there |
395
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
466 bool found = false; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
467 IRState::LoopScopeVec::reverse_iterator it; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
468 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
469 if(it->s == targetLoopStatement) { |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
470 llvm::BranchInst::Create(it->begin, gIR->scopebb()); |
395
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
471 found = true; |
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
472 break; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
473 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
474 } |
395
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
475 assert(found); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
476 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
477 else { |
311
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
478 // can't 'continue' within switch, so omit them |
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
479 IRState::LoopScopeVec::reverse_iterator it; |
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
480 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) { |
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
481 if(!it->isSwitch) { |
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
482 break; |
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
483 } |
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
484 } |
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
485 DtoEnclosingHandlers(enclosinghandler, it->enclosinghandler); |
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
486 llvm::BranchInst::Create(it->begin, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
487 } |
395
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
488 |
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
489 // the continue terminated this basicblock, start a new one |
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
490 llvm::BasicBlock* oldend = gIR->scopeend(); |
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
491 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftercontinue", p->topfunc(), oldend); |
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
492 p->scope() = IRScope(bb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
493 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
494 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
495 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
496 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
497 void OnScopeStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
498 { |
132 | 499 Logger::println("OnScopeStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
500 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
501 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
502 assert(statement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
503 //statement->toIR(p); // this seems to be redundant |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
504 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
505 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
506 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
507 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
508 void TryFinallyStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
509 { |
132 | 510 Logger::println("TryFinallyStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
511 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
512 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
513 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
514 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
515 |
652
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
516 // if there's no finalbody or no body, things are simple |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
517 if (!finalbody) { |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
518 if (body) |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
519 body->toIR(p); |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
520 return; |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
521 } |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
522 if (!body) { |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
523 finalbody->toIR(p); |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
524 return; |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
525 } |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
526 |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
527 // create basic blocks |
40 | 528 llvm::BasicBlock* oldend = p->scopeend(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
529 |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
530 llvm::BasicBlock* trybb = llvm::BasicBlock::Create("try", p->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
531 llvm::BasicBlock* finallybb = llvm::BasicBlock::Create("finally", p->topfunc(), oldend); |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
532 // the landing pad for statements in the try block |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
533 llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create("landingpad", p->topfunc(), oldend); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
534 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endtryfinally", p->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
535 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
536 // pass the previous BB into this |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
537 assert(!gIR->scopereturned()); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
538 llvm::BranchInst::Create(trybb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
539 |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
540 // |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
541 // set up the landing pad |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
542 // |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
543 p->scope() = IRScope(landingpadbb, endbb); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
544 |
652
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
545 assert(finalbody); |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
546 gIR->func()->landingPad.addFinally(finalbody); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
547 gIR->func()->landingPad.push(landingpadbb); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
548 |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
549 // |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
550 // do the try block |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
551 // |
40 | 552 p->scope() = IRScope(trybb,finallybb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
553 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
554 assert(body); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
555 body->toIR(p); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
556 |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
557 // terminate try BB |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
558 if (!p->scopereturned()) |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
559 llvm::BranchInst::Create(finallybb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
560 |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
561 gIR->func()->landingPad.pop(); |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
562 |
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
563 // |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
564 // do finally block |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
565 // |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
566 p->scope() = IRScope(finallybb,landingpadbb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
567 finalbody->toIR(p); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
568 |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
569 // terminate finally |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
570 //TODO: isn't it an error to have a 'returned' finally block? |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
571 if (!gIR->scopereturned()) { |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
572 llvm::BranchInst::Create(endbb, p->scopebb()); |
40 | 573 } |
574 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
575 // rewrite the scope |
40 | 576 p->scope() = IRScope(endbb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
577 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
578 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
579 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
580 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
581 void TryCatchStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
582 { |
132 | 583 Logger::println("TryCatchStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
584 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
585 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
586 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
587 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
588 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
589 // create basic blocks |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
590 llvm::BasicBlock* oldend = p->scopeend(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
591 |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
592 llvm::BasicBlock* trybb = llvm::BasicBlock::Create("try", p->topfunc(), oldend); |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
593 // the landing pad will be responsible for branching to the correct catch block |
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
594 llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create("landingpad", p->topfunc(), oldend); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
595 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endtrycatch", p->topfunc(), oldend); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
596 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
597 // pass the previous BB into this |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
598 assert(!gIR->scopereturned()); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
599 llvm::BranchInst::Create(trybb, p->scopebb()); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
600 |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
601 // |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
602 // do catches and the landing pad |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
603 // |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
604 assert(catches); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
605 gIR->scope() = IRScope(landingpadbb, endbb); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
606 |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
607 for (int i = 0; i < catches->dim; i++) |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
608 { |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
609 Catch *c = (Catch *)catches->data[i]; |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
610 gIR->func()->landingPad.addCatch(c, endbb); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
611 } |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
612 |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
613 gIR->func()->landingPad.push(landingpadbb); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
614 |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
615 // |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
616 // do the try block |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
617 // |
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
618 p->scope() = IRScope(trybb,landingpadbb); |
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
619 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
620 assert(body); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
621 body->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
622 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
623 if (!gIR->scopereturned()) |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
624 llvm::BranchInst::Create(endbb, p->scopebb()); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
625 |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
626 gIR->func()->landingPad.pop(); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
627 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
628 // rewrite the scope |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
629 p->scope() = IRScope(endbb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
630 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
631 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
632 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
633 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
634 void ThrowStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
635 { |
132 | 636 Logger::println("ThrowStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
637 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
638 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
639 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
640 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
641 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
642 assert(exp); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
643 DValue* e = exp->toElem(p); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
644 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_throw_exception"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
645 //Logger::cout() << "calling: " << *fn << '\n'; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
646 LLValue* arg = DtoBitCast(e->getRVal(), fn->getFunctionType()->getParamType(0)); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
647 //Logger::cout() << "arg: " << *arg << '\n'; |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
648 gIR->CreateCallOrInvoke(fn, arg); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
649 gIR->ir->CreateUnreachable(); |
309 | 650 |
651 // need a block after the throw for now | |
652 llvm::BasicBlock* oldend = gIR->scopeend(); | |
653 llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterthrow", p->topfunc(), oldend); | |
654 p->scope() = IRScope(bb,oldend); | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
655 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
656 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
657 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
658 |
122 | 659 // used to build the sorted list of cases |
660 struct Case : Object | |
661 { | |
662 StringExp* str; | |
663 size_t index; | |
664 | |
665 Case(StringExp* s, size_t i) { | |
666 str = s; | |
667 index = i; | |
668 } | |
669 | |
670 int compare(Object *obj) { | |
671 Case* c2 = (Case*)obj; | |
672 return str->compare(c2->str); | |
673 } | |
674 }; | |
675 | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
676 static LLValue* call_string_switch_runtime(llvm::GlobalVariable* table, Expression* e) |
122 | 677 { |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
678 Type* dt = e->type->toBasetype(); |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
679 Type* dtnext = dt->next->toBasetype(); |
122 | 680 TY ty = dtnext->ty; |
681 const char* fname; | |
682 if (ty == Tchar) { | |
683 fname = "_d_switch_string"; | |
684 } | |
685 else if (ty == Twchar) { | |
686 fname = "_d_switch_ustring"; | |
687 } | |
688 else if (ty == Tdchar) { | |
689 fname = "_d_switch_dstring"; | |
690 } | |
691 else { | |
692 assert(0 && "not char/wchar/dchar"); | |
693 } | |
694 | |
695 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname); | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
696 |
622
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
697 if (Logger::enabled()) |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
698 { |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
699 Logger::cout() << *table->getType() << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
700 Logger::cout() << *fn->getFunctionType()->getParamType(0) << '\n'; |
26fce59fe80a
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
611
diff
changeset
|
701 } |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
702 assert(table->getType() == fn->getFunctionType()->getParamType(0)); |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
703 |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
704 DValue* val = e->toElem(gIR); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
705 LLValue* llval; |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
706 if (DSliceValue* sval = val->isSlice()) |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
707 { |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
708 // give storage |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
709 llval = DtoAlloca(DtoType(e->type), "tmp"); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
519
diff
changeset
|
710 DVarValue* vv = new DVarValue(e->type, llval); |
399
0e6b4d65d3f8
Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents:
395
diff
changeset
|
711 DtoAssign(e->loc, vv, val); |
197
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
712 } |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
713 else |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
714 { |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
715 llval = val->getRVal(); |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
716 } |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
717 assert(llval->getType() == fn->getFunctionType()->getParamType(1)); |
bfcb657756f6
[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents:
185
diff
changeset
|
718 |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
719 CallOrInvoke* call = gIR->CreateCallOrInvoke2(fn, table, llval, "tmp"); |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
720 |
632
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
721 llvm::AttrListPtr palist; |
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
722 palist = palist.addAttr(1, llvm::Attribute::ByVal); |
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
723 palist = palist.addAttr(2, llvm::Attribute::ByVal); |
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
724 call->setAttributes(palist); |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
725 |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
726 return call->get(); |
122 | 727 } |
728 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
729 void SwitchStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
730 { |
132 | 731 Logger::println("SwitchStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
732 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
733 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
734 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
735 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
736 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
737 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
738 |
263
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
739 // clear data from previous passes... :/ |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
740 for (int i=0; i<cases->dim; ++i) |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
741 { |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
742 CaseStatement* cs = (CaseStatement*)cases->data[i]; |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
743 cs->bodyBB = NULL; |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
744 cs->llvmIdx = NULL; |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
745 } |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
746 |
122 | 747 // string switch? |
748 llvm::GlobalVariable* switchTable = 0; | |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
749 Array caseArray; |
122 | 750 if (!condition->type->isintegral()) |
751 { | |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
752 Logger::println("is string switch"); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
753 // build array of the stringexpS |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
754 caseArray.reserve(cases->dim); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
755 for (int i=0; i<cases->dim; ++i) |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
756 { |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
757 CaseStatement* cs = (CaseStatement*)cases->data[i]; |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
758 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
759 assert(cs->exp->op == TOKstring); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
760 caseArray.push(new Case((StringExp*)cs->exp, i)); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
761 } |
122 | 762 // first sort it |
763 caseArray.sort(); | |
764 // iterate and add indices to cases | |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
765 std::vector<LLConstant*> inits(caseArray.dim); |
122 | 766 for (size_t i=0; i<caseArray.dim; ++i) |
767 { | |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
768 Case* c = (Case*)caseArray.data[i]; |
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
769 CaseStatement* cs = (CaseStatement*)cases->data[c->index]; |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
770 cs->llvmIdx = DtoConstUint(i); |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
771 inits[i] = c->str->toConstElem(p); |
122 | 772 } |
773 // build static array for ptr or final array | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
774 const LLType* elemTy = DtoType(condition->type); |
122 | 775 const llvm::ArrayType* arrTy = llvm::ArrayType::get(elemTy, inits.size()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
776 LLConstant* arrInit = llvm::ConstantArray::get(arrTy, inits); |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
777 llvm::GlobalVariable* arr = new llvm::GlobalVariable(arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, ".string_switch_table_data", gIR->module); |
122 | 778 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
779 const LLType* elemPtrTy = getPtrToType(elemTy); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
780 LLConstant* arrPtr = llvm::ConstantExpr::getBitCast(arr, elemPtrTy); |
122 | 781 |
782 // build the static table | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
783 std::vector<const LLType*> types; |
122 | 784 types.push_back(DtoSize_t()); |
785 types.push_back(elemPtrTy); | |
786 const llvm::StructType* sTy = llvm::StructType::get(types); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
787 std::vector<LLConstant*> sinits; |
122 | 788 sinits.push_back(DtoConstSize_t(inits.size())); |
789 sinits.push_back(arrPtr); | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
790 LLConstant* sInit = llvm::ConstantStruct::get(sTy, sinits); |
122 | 791 |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
792 switchTable = new llvm::GlobalVariable(sTy, true, llvm::GlobalValue::InternalLinkage, sInit, ".string_switch_table", gIR->module); |
122 | 793 } |
794 | |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
795 // body block |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
796 llvm::BasicBlock* bodybb = llvm::BasicBlock::Create("switchbody", p->topfunc(), oldend); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
797 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
798 // default |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
799 llvm::BasicBlock* defbb = 0; |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
800 if (sdefault) { |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
801 Logger::println("has default"); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
802 defbb = llvm::BasicBlock::Create("default", p->topfunc(), oldend); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
803 sdefault->bodyBB = defbb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
804 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
805 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
806 // end (break point) |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
807 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("switchend", p->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
808 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
809 // condition var |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
810 LLValue* condVal; |
122 | 811 // integral switch |
812 if (condition->type->isintegral()) { | |
813 DValue* cond = condition->toElem(p); | |
814 condVal = cond->getRVal(); | |
815 } | |
816 // string switch | |
817 else { | |
818 condVal = call_string_switch_runtime(switchTable, condition); | |
819 } | |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
820 llvm::SwitchInst* si = llvm::SwitchInst::Create(condVal, defbb ? defbb : endbb, cases->dim, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
821 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
822 // do switch body |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
823 assert(body); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
824 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
825 p->scope() = IRScope(bodybb, endbb); |
311
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
826 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,p->scopebb(),endbb,true)); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
827 body->toIR(p); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
828 p->loopbbs.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
829 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
830 if (!p->scopereturned()) |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
831 llvm::BranchInst::Create(endbb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
832 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
833 // add the cases |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
834 for (int i=0; i<cases->dim; ++i) |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
835 { |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
836 CaseStatement* cs = (CaseStatement*)cases->data[i]; |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
837 si->addCase(cs->llvmIdx, cs->bodyBB); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
838 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
839 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
840 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
841 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
842 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
843 ////////////////////////////////////////////////////////////////////////////// |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
844 void CaseStatement::toIR(IRState* p) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
845 { |
132 | 846 Logger::println("CaseStatement::toIR(): %s", loc.toChars()); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
847 LOG_SCOPE; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
848 |
263
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
849 llvm::BasicBlock* nbb = llvm::BasicBlock::Create("case", p->topfunc(), p->scopeend()); |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
850 |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
851 if (bodyBB && !bodyBB->getTerminator()) |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
852 { |
263
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
853 llvm::BranchInst::Create(nbb, bodyBB); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
854 } |
263
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
855 bodyBB = nbb; |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
856 |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
857 if (llvmIdx == NULL) { |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
858 LLConstant* c = exp->toConstElem(p); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
859 llvmIdx = isaConstantInt(c); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
860 } |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
861 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
862 if (!p->scopereturned()) |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
863 llvm::BranchInst::Create(bodyBB, p->scopebb()); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
864 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
865 p->scope() = IRScope(bodyBB, p->scopeend()); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
866 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
867 assert(statement); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
868 statement->toIR(p); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
869 } |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
870 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
871 ////////////////////////////////////////////////////////////////////////////// |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
872 void DefaultStatement::toIR(IRState* p) |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
873 { |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
874 Logger::println("DefaultStatement::toIR(): %s", loc.toChars()); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
875 LOG_SCOPE; |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
876 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
877 assert(bodyBB); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
878 |
263
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
879 llvm::BasicBlock* nbb = llvm::BasicBlock::Create("default", p->topfunc(), p->scopeend()); |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
880 |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
881 if (!bodyBB->getTerminator()) |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
882 { |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
883 llvm::BranchInst::Create(nbb, bodyBB); |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
884 } |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
885 bodyBB = nbb; |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
886 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
887 if (!p->scopereturned()) |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
888 llvm::BranchInst::Create(bodyBB, p->scopebb()); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
889 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
890 p->scope() = IRScope(bodyBB, p->scopeend()); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
891 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
892 assert(statement); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
893 statement->toIR(p); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
894 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
895 |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
896 ////////////////////////////////////////////////////////////////////////////// |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
897 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
898 void UnrolledLoopStatement::toIR(IRState* p) |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
899 { |
132 | 900 Logger::println("UnrolledLoopStatement::toIR(): %s", loc.toChars()); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
901 LOG_SCOPE; |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
902 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
903 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
904 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
905 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
906 llvm::BasicBlock* oldend = gIR->scopeend(); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
907 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("unrolledend", p->topfunc(), oldend); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
908 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
909 p->scope() = IRScope(p->scopebb(),endbb); |
309 | 910 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,p->scopebb(),endbb)); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
911 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
912 for (int i=0; i<statements->dim; ++i) |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
913 { |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
914 Statement* s = (Statement*)statements->data[i]; |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
915 s->toIR(p); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
916 } |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
917 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
918 p->loopbbs.pop_back(); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
919 |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
920 llvm::BranchInst::Create(endbb, p->scopebb()); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
921 p->scope() = IRScope(endbb,oldend); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
922 } |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
923 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
924 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
925 |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
926 void ForeachStatement::toIR(IRState* p) |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
927 { |
132 | 928 Logger::println("ForeachStatement::toIR(): %s", loc.toChars()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
929 LOG_SCOPE; |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
930 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
931 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
932 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
933 |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
934 //assert(arguments->dim == 1); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
935 assert(value != 0); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
936 assert(aggr != 0); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
937 assert(func != 0); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
938 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
939 //Argument* arg = (Argument*)arguments->data[0]; |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
940 //Logger::println("Argument is %s", arg->toChars()); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
941 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
942 Logger::println("aggr = %s", aggr->toChars()); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
943 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
944 // key |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
945 const LLType* keytype = key ? DtoType(key->type) : DtoSize_t(); |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
946 LLValue* keyvar = DtoAlloca(keytype, "foreachkey"); |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
947 if (key) |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
948 { |
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
949 //key->llvmValue = keyvar; |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
950 assert(!key->ir.irLocal); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
951 key->ir.irLocal = new IrLocal(key); |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
952 key->ir.irLocal->value = keyvar; |
136
0e28624814e8
[svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
133
diff
changeset
|
953 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
954 LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
955 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
956 // value |
201 | 957 Logger::println("value = %s", value->toPrettyChars()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
958 const LLType* valtype = DtoType(value->type); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
959 LLValue* valvar = NULL; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
960 if (!value->isRef() && !value->isOut()) |
479
672eb4893b55
Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
Christian Kamm <kamm incasoftware de>
parents:
399
diff
changeset
|
961 valvar = DtoAlloca(valtype, "foreachval"); |
201 | 962 if (!value->ir.irLocal) |
963 value->ir.irLocal = new IrLocal(value); | |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
964 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
965 // what to iterate |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
966 DValue* aggrval = aggr->toElem(p); |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
479
diff
changeset
|
967 Type* aggrtype = aggr->type->toBasetype(); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
968 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
969 // get length and pointer |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
305
diff
changeset
|
970 LLValue* niters = DtoArrayLen(aggrval); |
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
305
diff
changeset
|
971 LLValue* val = DtoArrayPtr(aggrval); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
972 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
973 if (niters->getType() != keytype) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
974 { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
975 size_t sz1 = getTypeBitSize(niters->getType()); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
976 size_t sz2 = getTypeBitSize(keytype); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
977 if (sz1 < sz2) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
978 niters = gIR->ir->CreateZExt(niters, keytype, "foreachtrunckey"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
979 else if (sz1 > sz2) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
980 niters = gIR->ir->CreateTrunc(niters, keytype, "foreachtrunckey"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
981 else |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
982 niters = gIR->ir->CreateBitCast(niters, keytype, "foreachtrunckey"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
983 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
984 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
985 LLConstant* delta = 0; |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
986 if (op == TOKforeach) { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
987 new llvm::StoreInst(zerokey, keyvar, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
988 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
989 else { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
990 new llvm::StoreInst(niters, keyvar, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
991 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
992 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
993 llvm::BasicBlock* oldend = gIR->scopeend(); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
994 llvm::BasicBlock* condbb = llvm::BasicBlock::Create("foreachcond", p->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
995 llvm::BasicBlock* bodybb = llvm::BasicBlock::Create("foreachbody", p->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
996 llvm::BasicBlock* nextbb = llvm::BasicBlock::Create("foreachnext", p->topfunc(), oldend); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
997 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("foreachend", p->topfunc(), oldend); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
998 |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
999 llvm::BranchInst::Create(condbb, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1000 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1001 // condition |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1002 p->scope() = IRScope(condbb,bodybb); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1003 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1004 LLValue* done = 0; |
244
a95056b3c996
[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents:
234
diff
changeset
|
1005 LLValue* load = DtoLoad(keyvar); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1006 if (op == TOKforeach) { |
365 | 1007 done = p->ir->CreateICmpULT(load, niters, "tmp"); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1008 } |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1009 else if (op == TOKforeach_reverse) { |
365 | 1010 done = p->ir->CreateICmpUGT(load, zerokey, "tmp"); |
1011 load = p->ir->CreateSub(load, llvm::ConstantInt::get(keytype, 1, false), "tmp"); | |
1012 DtoStore(load, keyvar); | |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1013 } |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1014 llvm::BranchInst::Create(bodybb, endbb, done, p->scopebb()); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1015 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
1016 // init body |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1017 p->scope() = IRScope(bodybb,nextbb); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1018 |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1019 // get value for this iteration |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1020 LLConstant* zero = llvm::ConstantInt::get(keytype,0,false); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1021 LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp"); |
308
6b62e8cdf970
[svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents:
305
diff
changeset
|
1022 value->ir.irLocal->value = DtoGEP1(val,loadedKey); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
1023 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
1024 if (!value->isRef() && !value->isOut()) { |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
519
diff
changeset
|
1025 DVarValue dst(value->type, valvar); |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
519
diff
changeset
|
1026 DVarValue src(value->type, value->ir.irLocal->value); |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
519
diff
changeset
|
1027 DtoAssign(loc, &dst, &src); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1028 value->ir.irLocal->value = valvar; |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
1029 } |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1030 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
1031 // emit body |
309 | 1032 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,nextbb,endbb)); |
519
bc0835cd3440
Don't assert on empty foreach body.
Christian Kamm <kamm incasoftware de>
parents:
518
diff
changeset
|
1033 if(body) |
bc0835cd3440
Don't assert on empty foreach body.
Christian Kamm <kamm incasoftware de>
parents:
518
diff
changeset
|
1034 body->toIR(p); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1035 p->loopbbs.pop_back(); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1036 |
40 | 1037 if (!p->scopereturned()) |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1038 llvm::BranchInst::Create(nextbb, p->scopebb()); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1039 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1040 // next |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1041 p->scope() = IRScope(nextbb,endbb); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1042 if (op == TOKforeach) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1043 LLValue* load = DtoLoad(keyvar); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1044 load = p->ir->CreateAdd(load, llvm::ConstantInt::get(keytype, 1, false), "tmp"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1045 DtoStore(load, keyvar); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1046 } |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1047 llvm::BranchInst::Create(condbb, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1048 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1049 // end |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1050 p->scope() = IRScope(endbb,oldend); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1051 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1052 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1053 ////////////////////////////////////////////////////////////////////////////// |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1054 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1055 void LabelStatement::toIR(IRState* p) |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1056 { |
132 | 1057 Logger::println("LabelStatement::toIR(): %s", loc.toChars()); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1058 LOG_SCOPE; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1059 |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1060 // if it's an inline asm label, we don't create a basicblock, just emit it in the asm |
233
76ee1bbe487e
[svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents:
232
diff
changeset
|
1061 if (p->asmBlock) |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1062 { |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1063 IRAsmStmt* a = new IRAsmStmt; |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
1064 a->code += p->func()->decl->mangle(); |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
1065 a->code += "_"; |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1066 a->code += ident->toChars(); |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1067 a->code += ":"; |
233
76ee1bbe487e
[svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents:
232
diff
changeset
|
1068 p->asmBlock->s.push_back(a); |
299
df8a7b8d5929
[svn r320] Begun work on branches out of asm blocks. Unfinished.
ChristianK
parents:
298
diff
changeset
|
1069 p->asmBlock->internalLabels.push_back(ident); |
298
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1070 } |
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1071 else |
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1072 { |
355
d8357f7004ca
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents:
353
diff
changeset
|
1073 std::string labelname = p->func()->getScopedLabelName(ident->toChars()); |
353
a7a26f538d6e
[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents:
352
diff
changeset
|
1074 llvm::BasicBlock*& labelBB = p->func()->labelToBB[labelname]; |
a7a26f538d6e
[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents:
352
diff
changeset
|
1075 |
298
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1076 llvm::BasicBlock* oldend = gIR->scopeend(); |
353
a7a26f538d6e
[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents:
352
diff
changeset
|
1077 if (labelBB != NULL) { |
a7a26f538d6e
[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents:
352
diff
changeset
|
1078 labelBB->moveBefore(oldend); |
a7a26f538d6e
[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents:
352
diff
changeset
|
1079 } else { |
a7a26f538d6e
[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents:
352
diff
changeset
|
1080 labelBB = llvm::BasicBlock::Create("label", p->topfunc(), oldend); |
a7a26f538d6e
[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents:
352
diff
changeset
|
1081 } |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
1082 |
298
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1083 if (!p->scopereturned()) |
353
a7a26f538d6e
[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents:
352
diff
changeset
|
1084 llvm::BranchInst::Create(labelBB, p->scopebb()); |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
1085 |
353
a7a26f538d6e
[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents:
352
diff
changeset
|
1086 p->scope() = IRScope(labelBB,oldend); |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1087 } |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1088 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
1089 if (statement) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
1090 statement->toIR(p); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1091 } |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1092 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1093 ////////////////////////////////////////////////////////////////////////////// |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1094 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1095 void GotoStatement::toIR(IRState* p) |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1096 { |
132 | 1097 Logger::println("GotoStatement::toIR(): %s", loc.toChars()); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1098 LOG_SCOPE; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1099 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1100 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1101 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1102 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1103 llvm::BasicBlock* oldend = gIR->scopeend(); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1104 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergoto", p->topfunc(), oldend); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1105 |
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:
355
diff
changeset
|
1106 DtoGoto(&loc, label->ident, enclosinghandler, tf); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1107 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1108 p->scope() = IRScope(bb,oldend); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1109 } |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1110 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1111 ////////////////////////////////////////////////////////////////////////////// |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1112 |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1113 void GotoDefaultStatement::toIR(IRState* p) |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1114 { |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1115 Logger::println("GotoDefaultStatement::toIR(): %s", loc.toChars()); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1116 LOG_SCOPE; |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1117 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1118 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1119 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1120 |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1121 llvm::BasicBlock* oldend = gIR->scopeend(); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1122 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergotodefault", p->topfunc(), oldend); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1123 |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1124 assert(!p->scopereturned()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1125 assert(sw->sdefault->bodyBB); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1126 |
309 | 1127 DtoEnclosingHandlers(enclosinghandler, sw->enclosinghandler); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1128 |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1129 llvm::BranchInst::Create(sw->sdefault->bodyBB, p->scopebb()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1130 p->scope() = IRScope(bb,oldend); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1131 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1132 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1133 ////////////////////////////////////////////////////////////////////////////// |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1134 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1135 void GotoCaseStatement::toIR(IRState* p) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1136 { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1137 Logger::println("GotoCaseStatement::toIR(): %s", loc.toChars()); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1138 LOG_SCOPE; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1139 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1140 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1141 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1142 |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1143 llvm::BasicBlock* oldend = gIR->scopeend(); |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1144 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergotocase", p->topfunc(), oldend); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1145 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1146 assert(!p->scopereturned()); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
1147 if (!cs->bodyBB) |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
1148 { |
263
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
1149 cs->bodyBB = llvm::BasicBlock::Create("goto_case", p->topfunc(), p->scopeend()); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
1150 } |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1151 |
309 | 1152 DtoEnclosingHandlers(enclosinghandler, sw->enclosinghandler); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1153 |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1154 llvm::BranchInst::Create(cs->bodyBB, p->scopebb()); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1155 p->scope() = IRScope(bb,oldend); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1156 } |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1157 |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1158 ////////////////////////////////////////////////////////////////////////////// |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1159 |
40 | 1160 void WithStatement::toIR(IRState* p) |
1161 { | |
132 | 1162 Logger::println("WithStatement::toIR(): %s", loc.toChars()); |
40 | 1163 LOG_SCOPE; |
1164 | |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1165 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1166 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1167 |
40 | 1168 assert(exp); |
1169 assert(body); | |
1170 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
1171 DValue* e = exp->toElem(p); |
175
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
1172 assert(!wthis->ir.isSet()); |
c44e6a711885
[svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents:
173
diff
changeset
|
1173 wthis->ir.irLocal = new IrLocal(wthis); |
585
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
519
diff
changeset
|
1174 wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars()); |
fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
519
diff
changeset
|
1175 DtoStore(e->getRVal(), wthis->ir.irLocal->value); |
40 | 1176 |
1177 body->toIR(p); | |
1178 } | |
1179 | |
1180 ////////////////////////////////////////////////////////////////////////////// | |
1181 | |
309 | 1182 static LLConstant* generate_unique_critical_section() |
1183 { | |
1184 const LLType* Mty = DtoMutexType(); | |
1185 return new llvm::GlobalVariable(Mty, false, llvm::GlobalValue::InternalLinkage, LLConstant::getNullValue(Mty), ".uniqueCS", gIR->module); | |
1186 } | |
1187 | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1188 void SynchronizedStatement::toIR(IRState* p) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1189 { |
132 | 1190 Logger::println("SynchronizedStatement::toIR(): %s", loc.toChars()); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1191 LOG_SCOPE; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1192 |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1193 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1194 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1195 |
309 | 1196 // enter lock |
1197 if (exp) | |
1198 { | |
1199 llsync = exp->toElem(p)->getRVal(); | |
1200 DtoEnterMonitor(llsync); | |
1201 } | |
1202 else | |
1203 { | |
1204 llsync = generate_unique_critical_section(); | |
1205 DtoEnterCritical(llsync); | |
1206 } | |
1207 | |
1208 // emit body | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1209 body->toIR(p); |
309 | 1210 |
1211 // exit lock | |
1212 // no point in a unreachable unlock, terminating statements must insert this themselves. | |
1213 if (p->scopereturned()) | |
1214 return; | |
1215 else if (exp) | |
1216 DtoLeaveMonitor(llsync); | |
1217 else | |
1218 DtoLeaveCritical(llsync); | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1219 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1220 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1221 ////////////////////////////////////////////////////////////////////////////// |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1222 |
132 | 1223 void VolatileStatement::toIR(IRState* p) |
1224 { | |
1225 Logger::println("VolatileStatement::toIR(): %s", loc.toChars()); | |
1226 LOG_SCOPE; | |
1227 | |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1228 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1229 DtoDwarfStopPoint(loc.linnum); |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1230 |
206 | 1231 // mark in-volatile |
309 | 1232 // FIXME |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1233 |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1234 // has statement |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1235 if (statement != NULL) |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1236 { |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1237 // load-store |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1238 DtoMemoryBarrier(false, true, false, false); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1239 |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1240 // do statement |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1241 statement->toIR(p); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1242 |
309 | 1243 // no point in a unreachable barrier, terminating statements must insert this themselves. |
205
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1244 if (statement->fallOffEnd()) |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1245 { |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1246 // store-load |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1247 DtoMemoryBarrier(false, false, true, false); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1248 } |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1249 } |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1250 // barrier only |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1251 else |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1252 { |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1253 // load-store & store-load |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1254 DtoMemoryBarrier(false, true, true, false); |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1255 } |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1256 |
9d44ec83acd1
[svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents:
201
diff
changeset
|
1257 // restore volatile state |
309 | 1258 // FIXME |
132 | 1259 } |
1260 | |
1261 ////////////////////////////////////////////////////////////////////////////// | |
1262 | |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1263 void SwitchErrorStatement::toIR(IRState* p) |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1264 { |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1265 Logger::println("SwitchErrorStatement::toIR(): %s", loc.toChars()); |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1266 LOG_SCOPE; |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1267 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1268 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_switch_error"); |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1269 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1270 // param attrs |
632
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
1271 llvm::AttrListPtr palist; |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1272 int idx = 1; |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1273 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1274 std::vector<LLValue*> args; |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1275 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1276 // file param |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
652
diff
changeset
|
1277 args.push_back(gIR->dmodule->ir.irModule->fileName); |
632
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
1278 palist = palist.addAttr(idx++, llvm::Attribute::ByVal); |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1279 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1280 // line param |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
652
diff
changeset
|
1281 LLConstant* c = DtoConstUint(loc.linnum); |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1282 args.push_back(c); |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1283 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1284 // call |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1285 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end()); |
632
df196c8dea26
Updated to latest LLVM trunk, function notes have been removed and merged with parameter attributes, which have been renamed to just attributes. Nothing seems to have broke!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
622
diff
changeset
|
1286 call->setAttributes(palist); |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1287 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1288 gIR->ir->CreateUnreachable(); |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1289 } |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1290 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1291 ////////////////////////////////////////////////////////////////////////////// |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1292 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1293 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1294 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1295 #define STUBST(x) void x::toIR(IRState * p) {error("Statement type "#x" not implemented: %s", toChars());fatal();} |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1296 //STUBST(BreakStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1297 //STUBST(ForStatement); |
40 | 1298 //STUBST(WithStatement); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1299 //STUBST(SynchronizedStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1300 //STUBST(ReturnStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1301 //STUBST(ContinueStatement); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
1302 //STUBST(DefaultStatement); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
1303 //STUBST(CaseStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1304 //STUBST(SwitchStatement); |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1305 //STUBST(SwitchErrorStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1306 STUBST(Statement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1307 //STUBST(IfStatement); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1308 //STUBST(ForeachStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1309 //STUBST(DoStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1310 //STUBST(WhileStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1311 //STUBST(ExpStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1312 //STUBST(CompoundStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1313 //STUBST(ScopeStatement); |
131 | 1314 //STUBST(AsmStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1315 //STUBST(TryCatchStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1316 //STUBST(TryFinallyStatement); |
132 | 1317 //STUBST(VolatileStatement); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1318 //STUBST(LabelStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1319 //STUBST(ThrowStatement); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1320 //STUBST(GotoCaseStatement); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1321 //STUBST(GotoDefaultStatement); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1322 //STUBST(GotoStatement); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1323 //STUBST(UnrolledLoopStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1324 //STUBST(OnScopeStatement); |