Mercurial > projects > ldc
annotate gen/statements.cpp @ 1650:40bd4a0d4870
Update to work with LLVM 2.7.
Removed use of dyn_cast, llvm no compiles
without exceptions and rtti by
default. We do need exceptions for the libconfig stuff, but rtti isn't
necessary (anymore).
Debug info needs to be rewritten, as in LLVM 2.7 the format has
completely changed. To have something to look at while rewriting, the
old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means
that you have to define this to compile at the moment.
Updated tango 0.99.9 patch to include updated EH runtime code, which is
needed for LLVM 2.7 as well.
author | Tomas Lindquist Olsen |
---|---|
date | Wed, 19 May 2010 12:42:32 +0200 |
parents | 638a823ace45 |
children |
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 <fstream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
6 |
40 | 7 #include "gen/llvm.h" |
131 | 8 #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
|
9 #include "llvm/Support/CFG.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
10 |
132 | 11 #include "mars.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
12 #include "init.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
13 #include "mtype.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
14 #include "hdrgen.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
15 #include "port.h" |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
652
diff
changeset
|
16 #include "module.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
17 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
18 #include "gen/irstate.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
19 #include "gen/logger.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
20 #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
|
21 #include "gen/llvmhelpers.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
22 #include "gen/runtime.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
23 #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
|
24 #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
|
25 #include "gen/dvalue.h" |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
26 #include "gen/abi.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
27 |
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
|
28 #include "ir/irfunction.h" |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
652
diff
changeset
|
29 #include "ir/irmodule.h" |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
30 #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
|
31 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
32 ////////////////////////////////////////////////////////////////////////////// |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
33 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
34 void CompoundStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
35 { |
132 | 36 Logger::println("CompoundStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
37 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
38 |
34 | 39 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
|
40 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
41 Statement* s = (Statement*)statements->data[i]; |
132 | 42 if (s) { |
34 | 43 s->toIR(p); |
44 } | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
45 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
46 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
47 |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
48 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
49 ////////////////////////////////////////////////////////////////////////////// |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
50 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
51 void ReturnStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
52 { |
132 | 53 Logger::println("ReturnStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
54 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
55 |
1650 | 56 #ifndef DISABLE_DEBUG_INFO |
1549
327eef051d50
Always emit a stop point for return statements - even for void returns.
Christian Kamm <kamm incasoftware de>
parents:
1545
diff
changeset
|
57 if (global.params.symdebug) |
327eef051d50
Always emit a stop point for return statements - even for void returns.
Christian Kamm <kamm incasoftware de>
parents:
1545
diff
changeset
|
58 DtoDwarfStopPoint(loc.linnum); |
1650 | 59 #endif |
60 | |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
61 // is there a return value expression? |
1647
638a823ace45
Strange workaround for returning from within 'void main()'. The new dmdfe sets the ReturnStatement->exp to null. Fixed bug #391.
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1636
diff
changeset
|
62 if (exp || (!exp && (p->topfunc() == p->mainFunc)) ) |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
63 { |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
64 // if the functions return type is void this means that |
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
65 // we are returning through a pointer argument |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
66 if (p->topfunc()->getReturnType() == LLType::getVoidTy(gIR->context())) |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
67 { |
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
68 // sanity check |
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
|
69 IrFunction* f = p->func(); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
70 assert(f->decl->ir.irFunc->retArg); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
71 |
1042
45af482e3832
Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1024
diff
changeset
|
72 // FIXME: is there ever a case where a sret return needs to be rewritten for the ABI? |
45af482e3832
Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1024
diff
changeset
|
73 |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
74 // get return pointer |
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
|
75 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
|
76 DValue* e = exp->toElem(p); |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
77 // store return value |
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
|
78 DtoAssign(loc, rvar, e); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
79 |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
80 // emit scopes |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
81 DtoEnclosingHandlers(loc, 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
|
82 |
1650 | 83 #ifndef DISABLE_DEBUG_INFO |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
84 // emit dbg end function |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
85 if (global.params.symdebug) DtoDwarfFuncEnd(f->decl); |
1650 | 86 #endif |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
87 |
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
88 // emit ret |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
89 llvm::ReturnInst::Create(gIR->context(), p->scopebb()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
90 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
91 } |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
92 // the return type is not void, so this is a normal "register" return |
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
93 else |
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
94 { |
1647
638a823ace45
Strange workaround for returning from within 'void main()'. The new dmdfe sets the ReturnStatement->exp to null. Fixed bug #391.
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1636
diff
changeset
|
95 LLValue* v; |
638a823ace45
Strange workaround for returning from within 'void main()'. The new dmdfe sets the ReturnStatement->exp to null. Fixed bug #391.
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1636
diff
changeset
|
96 if (!exp && (p->topfunc() == p->mainFunc)) |
638a823ace45
Strange workaround for returning from within 'void main()'. The new dmdfe sets the ReturnStatement->exp to null. Fixed bug #391.
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1636
diff
changeset
|
97 v = LLConstant::getNullValue(p->mainFunc->getReturnType()); |
638a823ace45
Strange workaround for returning from within 'void main()'. The new dmdfe sets the ReturnStatement->exp to null. Fixed bug #391.
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1636
diff
changeset
|
98 else |
638a823ace45
Strange workaround for returning from within 'void main()'. The new dmdfe sets the ReturnStatement->exp to null. Fixed bug #391.
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1636
diff
changeset
|
99 // do abi specific transformations on the return value |
638a823ace45
Strange workaround for returning from within 'void main()'. The new dmdfe sets the ReturnStatement->exp to null. Fixed bug #391.
Kelly Wilson <wilsonk cpsc.ucalgary.ca>
parents:
1636
diff
changeset
|
100 v = p->func()->type->fty.putRet(exp->type, exp->toElem(p)); |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
101 |
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
|
102 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
|
103 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
|
104 |
1047
6bb04dbee21f
Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents:
1042
diff
changeset
|
105 IrFunction* f = p->func(); |
6bb04dbee21f
Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents:
1042
diff
changeset
|
106 // Hack around LDC assuming structs are in memory: |
6bb04dbee21f
Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents:
1042
diff
changeset
|
107 // If the function returns a struct, and the return value is a |
6bb04dbee21f
Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents:
1042
diff
changeset
|
108 // pointer to a struct, load from it before returning. |
6bb04dbee21f
Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents:
1042
diff
changeset
|
109 if (f->type->next->ty == Tstruct && isaPointer(v->getType())) { |
6bb04dbee21f
Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents:
1042
diff
changeset
|
110 Logger::println("Loading struct type for return"); |
6bb04dbee21f
Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents:
1042
diff
changeset
|
111 v = DtoLoad(v); |
6bb04dbee21f
Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents:
1042
diff
changeset
|
112 } |
6bb04dbee21f
Some calling convention work for x86-64:
Frits van Bommel <fvbommel wxs.nl>
parents:
1042
diff
changeset
|
113 |
974
815e1b8c6b00
Allow 'return exp;' for void main().
Christian Kamm <kamm incasoftware de>
parents:
945
diff
changeset
|
114 // can happen for classes and void main |
185
89e21eeaf4c4
[svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents:
181
diff
changeset
|
115 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
|
116 { |
976
fe93215deb82
Fix for fix from [974].
Christian Kamm <kamm incasoftware de>
parents:
974
diff
changeset
|
117 // for the main function this only happens if it is declared as void |
fe93215deb82
Fix for fix from [974].
Christian Kamm <kamm incasoftware de>
parents:
974
diff
changeset
|
118 // and then contains a return (exp); statement. Since the actual |
fe93215deb82
Fix for fix from [974].
Christian Kamm <kamm incasoftware de>
parents:
974
diff
changeset
|
119 // return type remains i32, we just throw away the exp value |
fe93215deb82
Fix for fix from [974].
Christian Kamm <kamm incasoftware de>
parents:
974
diff
changeset
|
120 // and return 0 instead |
fe93215deb82
Fix for fix from [974].
Christian Kamm <kamm incasoftware de>
parents:
974
diff
changeset
|
121 // if we're not in main, just bitcast |
fe93215deb82
Fix for fix from [974].
Christian Kamm <kamm incasoftware de>
parents:
974
diff
changeset
|
122 if (p->topfunc() == p->mainFunc) |
1560
1d5c3354b3c2
getNullValue is in Constant again
Benjamin Kramer <benny.kra@gmail.com>
parents:
1554
diff
changeset
|
123 v = LLConstant::getNullValue(p->mainFunc->getReturnType()); |
974
815e1b8c6b00
Allow 'return exp;' for void main().
Christian Kamm <kamm incasoftware de>
parents:
945
diff
changeset
|
124 else |
815e1b8c6b00
Allow 'return exp;' for void main().
Christian Kamm <kamm incasoftware de>
parents:
945
diff
changeset
|
125 v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp"); |
1024
9167d492cbc2
Abstracted more (most) ABI details out of the normal codegen.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1013
diff
changeset
|
126 |
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
|
127 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
|
128 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
|
129 } |
89e21eeaf4c4
[svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents:
181
diff
changeset
|
130 |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
131 DtoEnclosingHandlers(loc, 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
|
132 |
1650 | 133 #ifndef DISABLE_DEBUG_INFO |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
134 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
1650 | 135 #endif |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
136 llvm::ReturnInst::Create(gIR->context(), v, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
137 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
138 } |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
980
diff
changeset
|
139 // no return value expression means it's a void function |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
140 else |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
141 { |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
142 assert(p->topfunc()->getReturnType() == LLType::getVoidTy(gIR->context())); |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
143 DtoEnclosingHandlers(loc, NULL); |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
144 |
1650 | 145 #ifndef DISABLE_DEBUG_INFO |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
213
diff
changeset
|
146 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
1650 | 147 #endif |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
148 llvm::ReturnInst::Create(gIR->context(), p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
149 } |
267
c43911baea21
[svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents:
263
diff
changeset
|
150 |
c43911baea21
[svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents:
263
diff
changeset
|
151 // 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
|
152 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
153 llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "afterreturn", p->topfunc(), oldend); |
267
c43911baea21
[svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents:
263
diff
changeset
|
154 p->scope() = IRScope(bb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
155 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
156 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
157 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
158 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
159 void ExpStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
160 { |
132 | 161 Logger::println("ExpStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
162 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
163 |
1650 | 164 #ifndef DISABLE_DEBUG_INFO |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
165 if (global.params.symdebug) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
166 DtoDwarfStopPoint(loc.linnum); |
1650 | 167 #endif |
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
|
168 |
137 | 169 if (exp) { |
170 if (global.params.llvmAnnotate) | |
171 DtoAnnotation(exp->toChars()); | |
518
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
172 elem* e; |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
173 // 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
|
174 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
|
175 CastExp* cexp = (CastExp*)exp; |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
176 e = cexp->e1->toElem(p); |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
177 } |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
178 else |
243485af6523
Prevent cast error for cast(void) around expression statements.
Christian Kamm <kamm incasoftware de>
parents:
517
diff
changeset
|
179 e = exp->toElem(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
180 delete e; |
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 /*elem* e = exp->toElem(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
183 p->buf.printf("%s", e->toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
184 delete e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
185 p->buf.writenl();*/ |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
186 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
187 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
188 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
189 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
190 void IfStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
191 { |
132 | 192 Logger::println("IfStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
193 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
194 |
1650 | 195 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
196 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
197 DtoDwarfStopPoint(loc.linnum); |
1650 | 198 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
199 |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
200 if (match) |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
745
diff
changeset
|
201 DtoRawVarDeclaration(match); |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
202 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
203 DValue* cond_e = condition->toElem(p); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
204 LLValue* cond_val = cond_e->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
205 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
206 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
207 |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
208 llvm::BasicBlock* ifbb = llvm::BasicBlock::Create(gIR->context(), "if", gIR->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
209 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endif", gIR->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
210 llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create(gIR->context(), "else", gIR->topfunc(), endbb) : endbb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
211 |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
212 if (cond_val->getType() != LLType::getInt1Ty(gIR->context())) { |
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
|
213 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
|
214 Logger::cout() << "if conditional: " << *cond_val << '\n'; |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
774
diff
changeset
|
215 cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
216 } |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
217 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
|
218 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
219 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
220 gIR->scope() = IRScope(ifbb,elsebb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
221 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
222 // do scoped statements |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
223 if (ifbody) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
224 ifbody->toIR(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
225 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
|
226 llvm::BranchInst::Create(endbb,gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
227 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
228 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
229 if (elsebody) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
230 //assert(0); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
231 gIR->scope() = IRScope(elsebb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
232 elsebody->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
233 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
|
234 llvm::BranchInst::Create(endbb,gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
235 } |
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 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
238 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
239 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
240 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
241 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
242 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
243 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
244 void ScopeStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
245 { |
132 | 246 Logger::println("ScopeStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
247 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
248 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
249 /*llvm::BasicBlock* oldend = p->scopeend(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
250 |
40 | 251 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
|
252 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
253 // 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
|
254 llvm::BasicBlock* bb = p->scopebb(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
255 if (bb->empty()) { |
40 | 256 beginbb = bb; |
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 else { |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
259 beginbb = llvm::BasicBlock::Create(gIR->context(), "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
|
260 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
|
261 llvm::BranchInst::Create(beginbb, bb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
262 } |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
263 |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
264 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "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
|
265 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
|
266 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
|
267 else |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
268 p->scope().end = endbb;*/ |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
269 |
181
ef4108f34db6
[svn r197] Fixed: empty scope statement segfaulted.
lindquist
parents:
175
diff
changeset
|
270 if (statement) |
ef4108f34db6
[svn r197] Fixed: empty scope statement segfaulted.
lindquist
parents:
175
diff
changeset
|
271 statement->toIR(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
272 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
273 /*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
|
274 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
|
275 endbb->eraseFromParent();*/ |
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 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
278 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
279 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
280 void WhileStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
281 { |
132 | 282 Logger::println("WhileStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
283 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
284 |
1650 | 285 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
286 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
287 DtoDwarfStopPoint(loc.linnum); |
1650 | 288 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
289 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
290 // create while blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
291 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
292 llvm::BasicBlock* whilebb = llvm::BasicBlock::Create(gIR->context(), "whilecond", gIR->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
293 llvm::BasicBlock* whilebodybb = llvm::BasicBlock::Create(gIR->context(), "whilebody", gIR->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
294 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endwhile", gIR->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
295 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
296 // move into the while block |
40 | 297 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
|
298 //llvm::BranchInst::Create(whilebb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
299 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
300 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
301 gIR->scope() = IRScope(whilebb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
302 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
303 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
304 DValue* cond_e = condition->toElem(p); |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
774
diff
changeset
|
305 LLValue* cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
306 delete cond_e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
307 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
308 // conditional branch |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
309 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
|
310 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
311 // rewrite scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
312 gIR->scope() = IRScope(whilebodybb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
313 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
314 // while body code |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
315 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,whilebb,endbb)); |
1636 | 316 if (body) |
317 body->toIR(p); | |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
318 p->func()->gen->targetScopes.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
319 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
320 // loop |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
321 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
|
322 llvm::BranchInst::Create(whilebb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
323 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
324 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
325 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
326 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
327 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
328 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
329 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
330 void DoStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
331 { |
132 | 332 Logger::println("DoStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
333 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
334 |
1650 | 335 #ifndef DISABLE_DEBUG_INFO |
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); |
1650 | 338 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
339 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
340 // create while blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
341 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
342 llvm::BasicBlock* dowhilebb = llvm::BasicBlock::Create(gIR->context(), "dowhile", gIR->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
343 llvm::BasicBlock* condbb = llvm::BasicBlock::Create(gIR->context(), "dowhilecond", gIR->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
344 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "enddowhile", 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 // move into the while block |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
347 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
|
348 llvm::BranchInst::Create(dowhilebb, gIR->scopebb()); |
14
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 // replace current scope |
517
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
351 gIR->scope() = IRScope(dowhilebb,condbb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
352 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
353 // do-while body code |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
354 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,condbb,endbb)); |
1636 | 355 if (body) |
356 body->toIR(p); | |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
357 p->func()->gen->targetScopes.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
358 |
517
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
359 // branch to condition block |
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
360 llvm::BranchInst::Create(condbb, gIR->scopebb()); |
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
361 gIR->scope() = IRScope(condbb,endbb); |
9534dbc70a56
Fix continue inside dowhile statements.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
362 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
363 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
364 DValue* cond_e = condition->toElem(p); |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
774
diff
changeset
|
365 LLValue* cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
366 delete cond_e; |
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 // conditional branch |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
369 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
|
370 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
371 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
372 gIR->scope() = IRScope(endbb,oldend); |
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 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
375 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
376 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
377 void ForStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
378 { |
132 | 379 Logger::println("ForStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
380 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
381 |
1650 | 382 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
383 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
384 DtoDwarfStopPoint(loc.linnum); |
1650 | 385 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
386 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
387 // create for blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
388 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
389 llvm::BasicBlock* forbb = llvm::BasicBlock::Create(gIR->context(), "forcond", gIR->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
390 llvm::BasicBlock* forbodybb = llvm::BasicBlock::Create(gIR->context(), "forbody", gIR->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
391 llvm::BasicBlock* forincbb = llvm::BasicBlock::Create(gIR->context(), "forinc", gIR->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
392 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endfor", gIR->topfunc(), oldend); |
14
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 // init |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
395 if (init != 0) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
396 init->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
397 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
398 // 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
|
399 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
|
400 llvm::BranchInst::Create(forbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
401 |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
402 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,forincbb,endbb)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
403 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
404 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
405 gIR->scope() = IRScope(forbb,forbodybb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
406 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
407 // create the condition |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
408 LLValue* cond_val; |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
409 if (condition) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
410 { |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
411 DValue* cond_e = condition->toElem(p); |
778
4adf0f742896
Get rid of DtoBoolean - use DtoCast(... Type::tbool) instead.
Christian Kamm <kamm incasoftware de>
parents:
774
diff
changeset
|
412 cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal(); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
413 delete cond_e; |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
414 } |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
415 else |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
416 { |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
417 cond_val = DtoConstBool(true); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
418 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
419 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
420 // conditional branch |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
421 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
|
422 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
|
423 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
424 // rewrite scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
425 gIR->scope() = IRScope(forbodybb,forincbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
426 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
427 // do for body code |
1636 | 428 if (body) |
429 body->toIR(p); | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
430 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
431 // move into the for increment block |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
432 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
|
433 llvm::BranchInst::Create(forincbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
434 gIR->scope() = IRScope(forincbb, endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
435 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
436 // increment |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
437 if (increment) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
438 DValue* inc = increment->toElem(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
439 delete inc; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
440 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
441 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
442 // loop |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
443 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
|
444 llvm::BranchInst::Create(forbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
445 |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
446 p->func()->gen->targetScopes.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
447 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
448 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
449 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
450 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
451 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
452 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
453 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
454 void BreakStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
455 { |
132 | 456 Logger::println("BreakStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
457 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
458 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
459 // 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
|
460 // 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
|
461 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
|
462 return; |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
463 |
1650 | 464 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
465 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
466 DtoDwarfStopPoint(loc.linnum); |
1650 | 467 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
468 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
469 if (ident != 0) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
470 Logger::println("ident = %s", ident->toChars()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
471 |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
472 DtoEnclosingHandlers(loc, target); |
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 // get the loop statement the label refers to |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
475 Statement* targetLoopStatement = target->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
476 ScopeStatement* tmp; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
477 while(tmp = targetLoopStatement->isScopeStatement()) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
478 targetLoopStatement = tmp->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
479 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
480 // 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
|
481 bool found = false; |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
482 FuncGen::TargetScopeVec::reverse_iterator it = p->func()->gen->targetScopes.rbegin(); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
483 FuncGen::TargetScopeVec::reverse_iterator it_end = p->func()->gen->targetScopes.rend(); |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
484 while(it != it_end) { |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
485 if(it->s == targetLoopStatement) { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
486 llvm::BranchInst::Create(it->breakTarget, p->scopebb()); |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
487 found = true; |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
488 break; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
489 } |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
490 ++it; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
491 } |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
492 assert(found); |
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 else { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
495 // find closest scope with a break target |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
496 FuncGen::TargetScopeVec::reverse_iterator it = p->func()->gen->targetScopes.rbegin(); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
497 FuncGen::TargetScopeVec::reverse_iterator it_end = p->func()->gen->targetScopes.rend(); |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
498 while(it != it_end) { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
499 if(it->breakTarget) { |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
500 break; |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
501 } |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
502 ++it; |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
503 } |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
504 DtoEnclosingHandlers(loc, it->s); |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
505 llvm::BranchInst::Create(it->breakTarget, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
506 } |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
507 |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
508 // 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
|
509 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
510 llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "afterbreak", p->topfunc(), oldend); |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
268
diff
changeset
|
511 p->scope() = IRScope(bb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
512 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
513 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
514 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
515 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
516 void ContinueStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
517 { |
132 | 518 Logger::println("ContinueStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
519 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
520 |
1650 | 521 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
522 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
523 DtoDwarfStopPoint(loc.linnum); |
1650 | 524 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
525 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
526 if (ident != 0) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
527 Logger::println("ident = %s", ident->toChars()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
528 |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
529 DtoEnclosingHandlers(loc, target); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
530 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
531 // get the loop statement the label refers to |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
532 Statement* targetLoopStatement = target->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
533 ScopeStatement* tmp; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
534 while(tmp = targetLoopStatement->isScopeStatement()) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
535 targetLoopStatement = tmp->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
536 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
537 // 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
|
538 bool found = false; |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
539 FuncGen::TargetScopeVec::reverse_iterator it = p->func()->gen->targetScopes.rbegin(); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
540 FuncGen::TargetScopeVec::reverse_iterator it_end = p->func()->gen->targetScopes.rend(); |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
541 while(it != it_end) { |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
542 if(it->s == targetLoopStatement) { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
543 llvm::BranchInst::Create(it->continueTarget, gIR->scopebb()); |
395
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
544 found = true; |
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
545 break; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
546 } |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
547 ++it; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
548 } |
395
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
549 assert(found); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
550 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
551 else { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
552 // find closest scope with a continue target |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
553 FuncGen::TargetScopeVec::reverse_iterator it = p->func()->gen->targetScopes.rbegin(); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
554 FuncGen::TargetScopeVec::reverse_iterator it_end = p->func()->gen->targetScopes.rend(); |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
555 while(it != it_end) { |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
556 if(it->continueTarget) { |
311
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
557 break; |
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
558 } |
1145
40caa8207b3e
Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1141
diff
changeset
|
559 ++it; |
311
9967a3270837
[svn r332] Fix codegen for continue within switch.
ChristianK
parents:
309
diff
changeset
|
560 } |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
561 DtoEnclosingHandlers(loc, it->s); |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
562 llvm::BranchInst::Create(it->continueTarget, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
563 } |
395
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
564 |
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
565 // 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
|
566 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
567 llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftercontinue", p->topfunc(), oldend); |
395
71a40b62b408
Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents:
365
diff
changeset
|
568 p->scope() = IRScope(bb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
569 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
570 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
571 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
572 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
573 void OnScopeStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
574 { |
132 | 575 Logger::println("OnScopeStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
576 LOG_SCOPE; |
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 assert(statement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
579 //statement->toIR(p); // this seems to be redundant |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
580 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
581 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
582 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
583 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
584 void TryFinallyStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
585 { |
132 | 586 Logger::println("TryFinallyStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
587 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
588 |
1650 | 589 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
590 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
591 DtoDwarfStopPoint(loc.linnum); |
1650 | 592 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
593 |
652
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
594 // 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
|
595 if (!finalbody) { |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
596 if (body) |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
597 body->toIR(p); |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
598 return; |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
599 } |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
600 if (!body) { |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
601 finalbody->toIR(p); |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
602 return; |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
603 } |
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
604 |
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
|
605 // create basic blocks |
40 | 606 llvm::BasicBlock* oldend = p->scopeend(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
607 |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
608 llvm::BasicBlock* trybb = llvm::BasicBlock::Create(gIR->context(), "try", p->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
609 llvm::BasicBlock* finallybb = llvm::BasicBlock::Create(gIR->context(), "finally", p->topfunc(), oldend); |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
610 // the landing pad for statements in the try block |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
611 llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create(gIR->context(), "landingpad", p->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
612 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endtryfinally", p->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
613 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
614 // 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
|
615 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
|
616 llvm::BranchInst::Create(trybb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
617 |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
618 // |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
619 // set up the landing pad |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
620 // |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
621 p->scope() = IRScope(landingpadbb, endbb); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
622 |
652
c8fcde3337b0
Fix TryFinally without body or finalbody.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
623 assert(finalbody); |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
624 IRLandingPad& pad = gIR->func()->gen->landingPadInfo; |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
625 pad.addFinally(finalbody); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
626 pad.push(landingpadbb); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
627 gIR->func()->gen->targetScopes.push_back(IRTargetScope(this,new EnclosingTryFinally(this,gIR->func()->gen->landingPad),NULL,NULL)); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
628 gIR->func()->gen->landingPad = pad.get(); |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
629 |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
630 // |
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
|
631 // do the try block |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
632 // |
40 | 633 p->scope() = IRScope(trybb,finallybb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
634 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
635 assert(body); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
636 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
|
637 |
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
|
638 // 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
|
639 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
|
640 llvm::BranchInst::Create(finallybb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
641 |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
642 pad.pop(); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
643 gIR->func()->gen->landingPad = pad.get(); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
644 gIR->func()->gen->targetScopes.pop_back(); |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
645 |
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
646 // |
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
|
647 // do finally block |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
648 // |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
649 p->scope() = IRScope(finallybb,landingpadbb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
650 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
|
651 |
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
|
652 // terminate finally |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
653 //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
|
654 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
|
655 llvm::BranchInst::Create(endbb, p->scopebb()); |
40 | 656 } |
657 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
658 // rewrite the scope |
40 | 659 p->scope() = IRScope(endbb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
660 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
661 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
662 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
663 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
664 void TryCatchStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
665 { |
132 | 666 Logger::println("TryCatchStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
667 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
668 |
1650 | 669 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
670 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
671 DtoDwarfStopPoint(loc.linnum); |
1650 | 672 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
673 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
674 // create basic blocks |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
675 llvm::BasicBlock* oldend = p->scopeend(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
676 |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
677 llvm::BasicBlock* trybb = llvm::BasicBlock::Create(gIR->context(), "try", p->topfunc(), oldend); |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
678 // the landing pad will be responsible for branching to the correct catch block |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
679 llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create(gIR->context(), "landingpad", p->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
680 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "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
|
681 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
682 // 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
|
683 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
|
684 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
|
685 |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
686 // |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
687 // do catches and the landing pad |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
688 // |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
689 assert(catches); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
690 gIR->scope() = IRScope(landingpadbb, endbb); |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
691 |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
692 IRLandingPad& pad = gIR->func()->gen->landingPadInfo; |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
693 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
|
694 { |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
695 Catch *c = (Catch *)catches->data[i]; |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
696 pad.addCatch(c, endbb); |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
697 } |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
698 |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
699 pad.push(landingpadbb); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
700 gIR->func()->gen->landingPad = pad.get(); |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
701 |
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
702 // |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
703 // do the try block |
314
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
704 // |
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
705 p->scope() = IRScope(trybb,landingpadbb); |
8d98e42ece93
[svn r335] The basics of exception handling are in place.
ChristianK
parents:
311
diff
changeset
|
706 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
707 assert(body); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
708 body->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
709 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
710 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
|
711 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
|
712 |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
713 pad.pop(); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
714 gIR->func()->gen->landingPad = pad.get(); |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
715 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
716 // rewrite the scope |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
717 p->scope() = IRScope(endbb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
718 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
719 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
720 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
721 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
722 void ThrowStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
723 { |
132 | 724 Logger::println("ThrowStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
725 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
726 |
1650 | 727 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
728 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
729 DtoDwarfStopPoint(loc.linnum); |
1650 | 730 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
731 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
732 assert(exp); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
733 DValue* e = exp->toElem(p); |
687
0a682c7805d2
Emit region.end debug calls before a throw.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
734 |
1650 | 735 #ifndef DISABLE_DEBUG_INFO |
687
0a682c7805d2
Emit region.end debug calls before a throw.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
736 if (global.params.symdebug) DtoDwarfFuncEnd(gIR->func()->decl); |
1650 | 737 #endif |
687
0a682c7805d2
Emit region.end debug calls before a throw.
Christian Kamm <kamm incasoftware de>
parents:
683
diff
changeset
|
738 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
739 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
|
740 //Logger::cout() << "calling: " << *fn << '\n'; |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
741 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
|
742 //Logger::cout() << "arg: " << *arg << '\n'; |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
743 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
|
744 gIR->ir->CreateUnreachable(); |
309 | 745 |
746 // need a block after the throw for now | |
747 llvm::BasicBlock* oldend = gIR->scopeend(); | |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
748 llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "afterthrow", p->topfunc(), oldend); |
309 | 749 p->scope() = IRScope(bb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
750 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
751 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
752 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
753 |
122 | 754 // used to build the sorted list of cases |
755 struct Case : Object | |
756 { | |
757 StringExp* str; | |
758 size_t index; | |
759 | |
760 Case(StringExp* s, size_t i) { | |
761 str = s; | |
762 index = i; | |
763 } | |
764 | |
765 int compare(Object *obj) { | |
766 Case* c2 = (Case*)obj; | |
767 return str->compare(c2->str); | |
768 } | |
769 }; | |
770 | |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
704
diff
changeset
|
771 static LLValue* call_string_switch_runtime(llvm::Value* table, Expression* e) |
122 | 772 { |
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
|
773 Type* dt = e->type->toBasetype(); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
774 Type* dtnext = dt->nextOf()->toBasetype(); |
122 | 775 TY ty = dtnext->ty; |
776 const char* fname; | |
777 if (ty == Tchar) { | |
778 fname = "_d_switch_string"; | |
779 } | |
780 else if (ty == Twchar) { | |
781 fname = "_d_switch_ustring"; | |
782 } | |
783 else if (ty == Tdchar) { | |
784 fname = "_d_switch_dstring"; | |
785 } | |
786 else { | |
787 assert(0 && "not char/wchar/dchar"); | |
788 } | |
789 | |
790 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
|
791 |
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
|
792 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
|
793 { |
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
|
794 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
|
795 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
|
796 } |
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
|
797 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
|
798 |
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
|
799 DValue* val = e->toElem(gIR); |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
704
diff
changeset
|
800 LLValue* llval = val->getRVal(); |
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
|
801 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
|
802 |
1013
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
994
diff
changeset
|
803 LLCallSite call = gIR->CreateCallOrInvoke2(fn, table, llval, "tmp"); |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
804 |
1013
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
994
diff
changeset
|
805 return call.getInstruction(); |
122 | 806 } |
807 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
808 void SwitchStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
809 { |
132 | 810 Logger::println("SwitchStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
811 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
812 |
1650 | 813 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
814 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
815 DtoDwarfStopPoint(loc.linnum); |
1650 | 816 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
817 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
818 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
819 |
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
|
820 // 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
|
821 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
|
822 { |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
823 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
|
824 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
|
825 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
|
826 } |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
827 |
122 | 828 // string switch? |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
704
diff
changeset
|
829 llvm::Value* 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
|
830 Array caseArray; |
122 | 831 if (!condition->type->isintegral()) |
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 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
|
834 // build array of the stringexpS |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
835 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
|
836 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
|
837 { |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
838 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
|
839 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
840 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
|
841 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
|
842 } |
122 | 843 // first sort it |
844 caseArray.sort(); | |
845 // iterate and add indices to cases | |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
846 std::vector<LLConstant*> inits(caseArray.dim); |
122 | 847 for (size_t i=0; i<caseArray.dim; ++i) |
848 { | |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
849 Case* c = (Case*)caseArray.data[i]; |
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
850 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
|
851 cs->llvmIdx = DtoConstUint(i); |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
852 inits[i] = c->str->toConstElem(p); |
122 | 853 } |
854 // 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
|
855 const LLType* elemTy = DtoType(condition->type); |
122 | 856 const llvm::ArrayType* arrTy = llvm::ArrayType::get(elemTy, inits.size()); |
1554
d6e8d5db259f
LLVMContext changes up to r77366
Benjamin Kramer <benny.kra@gmail.com>
parents:
1549
diff
changeset
|
857 LLConstant* arrInit = LLConstantArray::get(arrTy, inits); |
1529
ad7f2f1862d6
Adjust LDC to work with the LLVMContext LLVM changes.
Christian Kamm <kamm incasoftware de>
parents:
1508
diff
changeset
|
858 llvm::GlobalVariable* arr = new llvm::GlobalVariable(*gIR->module, arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, ".string_switch_table_data"); |
122 | 859 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
860 const LLType* elemPtrTy = getPtrToType(elemTy); |
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
861 LLConstant* arrPtr = llvm::ConstantExpr::getBitCast(arr, elemPtrTy); |
122 | 862 |
863 // build the static table | |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
864 std::vector<const LLType*> types; |
122 | 865 types.push_back(DtoSize_t()); |
866 types.push_back(elemPtrTy); | |
1569
755abafbf25d
Push the context through StructType::get.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1560
diff
changeset
|
867 const llvm::StructType* sTy = llvm::StructType::get(gIR->context(), types); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
868 std::vector<LLConstant*> sinits; |
122 | 869 sinits.push_back(DtoConstSize_t(inits.size())); |
870 sinits.push_back(arrPtr); | |
715
30b42a283c8e
Removed TypeOpaque from DMD.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
704
diff
changeset
|
871 switchTable = llvm::ConstantStruct::get(sTy, sinits); |
122 | 872 } |
873 | |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
874 // body block |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
875 llvm::BasicBlock* bodybb = llvm::BasicBlock::Create(gIR->context(), "switchbody", 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
|
876 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
877 // default |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
878 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
|
879 if (sdefault) { |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
880 Logger::println("has default"); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
881 defbb = llvm::BasicBlock::Create(gIR->context(), "default", p->topfunc(), oldend); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
882 sdefault->bodyBB = defbb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
883 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
884 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
885 // end (break point) |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
886 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "switchend", p->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
887 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
888 // condition var |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
889 LLValue* condVal; |
122 | 890 // integral switch |
891 if (condition->type->isintegral()) { | |
892 DValue* cond = condition->toElem(p); | |
893 condVal = cond->getRVal(); | |
894 } | |
895 // string switch | |
896 else { | |
897 condVal = call_string_switch_runtime(switchTable, condition); | |
898 } | |
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
|
899 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
|
900 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
901 // 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
|
902 assert(body); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
903 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
904 p->scope() = IRScope(bodybb, endbb); |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
905 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,NULL,endbb)); |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
906 body->toIR(p); |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
907 p->func()->gen->targetScopes.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
908 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
909 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
|
910 llvm::BranchInst::Create(endbb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
911 |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
912 // 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
|
913 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
|
914 { |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
915 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
|
916 si->addCase(cs->llvmIdx, cs->bodyBB); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
917 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
918 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
919 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
920 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
921 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
922 ////////////////////////////////////////////////////////////////////////////// |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
923 void CaseStatement::toIR(IRState* p) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
924 { |
132 | 925 Logger::println("CaseStatement::toIR(): %s", loc.toChars()); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
926 LOG_SCOPE; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
927 |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
928 llvm::BasicBlock* nbb = llvm::BasicBlock::Create(gIR->context(), "case", p->topfunc(), p->scopeend()); |
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
|
929 |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
930 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
|
931 { |
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
|
932 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
|
933 } |
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
|
934 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
|
935 |
271
1e6e2b5d5bfe
[svn r292] Fixed: string switch was broken in several ways.
lindquist
parents:
270
diff
changeset
|
936 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
|
937 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
|
938 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
|
939 } |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
940 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
941 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
|
942 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
|
943 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
944 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
|
945 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
946 assert(statement); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
947 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
|
948 } |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
949 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
950 ////////////////////////////////////////////////////////////////////////////// |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
951 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
|
952 { |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
953 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
|
954 LOG_SCOPE; |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
955 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
956 assert(bodyBB); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
957 |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
958 llvm::BasicBlock* nbb = llvm::BasicBlock::Create(gIR->context(), "default", p->topfunc(), p->scopeend()); |
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
|
959 |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
960 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
|
961 { |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
962 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
|
963 } |
2be09ee06bc7
[svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents:
262
diff
changeset
|
964 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
|
965 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
966 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
|
967 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
|
968 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
969 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
|
970 |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
971 assert(statement); |
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
244
diff
changeset
|
972 statement->toIR(p); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
973 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
974 |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
975 ////////////////////////////////////////////////////////////////////////////// |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
976 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
977 void UnrolledLoopStatement::toIR(IRState* p) |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
978 { |
132 | 979 Logger::println("UnrolledLoopStatement::toIR(): %s", loc.toChars()); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
980 LOG_SCOPE; |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
981 |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
982 // if no statements, there's nothing to do |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
983 if (!statements || !statements->dim) |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
984 return; |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
985 |
1650 | 986 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
987 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
988 DtoDwarfStopPoint(loc.linnum); |
1650 | 989 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
990 |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
991 // DMD doesn't fold stuff like continue/break, and since this isn't really a loop |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
778
diff
changeset
|
992 // we have to keep track of each statement and jump to the next/end on continue/break |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
993 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
994 llvm::BasicBlock* oldend = gIR->scopeend(); |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
995 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
996 // create a block for each statement |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
997 size_t nstmt = statements->dim; |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
998 LLSmallVector<llvm::BasicBlock*, 4> blocks(nstmt, NULL); |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
999 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1000 for (size_t i=0; i<nstmt; i++) |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1001 { |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1002 blocks[i] = llvm::BasicBlock::Create(gIR->context(), "unrolledstmt", p->topfunc(), oldend); |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1003 } |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1004 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1005 // create end block |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1006 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "unrolledend", p->topfunc(), oldend); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1007 |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1008 // enter first stmt |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1009 if (!p->scopereturned()) |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1010 p->ir->CreateBr(blocks[0]); |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1011 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1012 // do statements |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1013 Statement** stmts = (Statement**)statements->data; |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1014 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1015 for (int i=0; i<nstmt; i++) |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1016 { |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1017 Statement* s = stmts[i]; |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1018 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1019 // get blocks |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1020 llvm::BasicBlock* thisbb = blocks[i]; |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1021 llvm::BasicBlock* nextbb = (i+1 == nstmt) ? endbb : blocks[i+1]; |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1022 |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1023 // update scope |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1024 p->scope() = IRScope(thisbb,nextbb); |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1025 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1026 // push loop scope |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1027 // continue goes to next statement, break goes to end |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1028 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,nextbb,endbb)); |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1029 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1030 // do statement |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1031 s->toIR(p); |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1032 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1033 // pop loop scope |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1034 p->func()->gen->targetScopes.pop_back(); |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1035 |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1036 // next stmt |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1037 if (!p->scopereturned()) |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1038 p->ir->CreateBr(nextbb); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1039 } |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1040 |
774
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1041 // finish scope |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1042 if (!p->scopereturned()) |
9688da40cd4d
Fixed problem with continue/break in unrolled loop statements.
tomas@myhost
parents:
758
diff
changeset
|
1043 p->ir->CreateBr(endbb); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1044 p->scope() = IRScope(endbb,oldend); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1045 } |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1046 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1047 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1048 |
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
|
1049 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
|
1050 { |
132 | 1051 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
|
1052 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
|
1053 |
1650 | 1054 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1055 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1056 DtoDwarfStopPoint(loc.linnum); |
1650 | 1057 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1058 |
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
|
1059 //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
|
1060 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
|
1061 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
|
1062 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
|
1063 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1064 //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
|
1065 //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
|
1066 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1067 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
|
1068 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1069 // key |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1070 const LLType* keytype = key ? DtoType(key->type) : DtoSize_t(); |
745
5761d7e6f628
Tried using DtoDeclarationExp for VarDecls in Statements to fix nesting issues
Christian Kamm <kamm incasoftware de>
parents:
733
diff
changeset
|
1071 LLValue* 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
|
1072 if (key) |
747
46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
745
diff
changeset
|
1073 keyvar = DtoRawVarDeclaration(key); |
745
5761d7e6f628
Tried using DtoDeclarationExp for VarDecls in Statements to fix nesting issues
Christian Kamm <kamm incasoftware de>
parents:
733
diff
changeset
|
1074 else |
1350
15e9762bb620
Adds explicit alignment information for alloca instructions in general, there's a few cases that still needs to be looked at but this should catch the majority. Fixes ticket #293 .
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1271
diff
changeset
|
1075 keyvar = DtoRawAlloca(keytype, 0, "foreachkey"); // FIXME: align? |
1554
d6e8d5db259f
LLVMContext changes up to r77366
Benjamin Kramer <benny.kra@gmail.com>
parents:
1549
diff
changeset
|
1076 LLValue* zerokey = LLConstantInt::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
|
1077 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1078 // value |
201 | 1079 Logger::println("value = %s", value->toPrettyChars()); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1080 LLValue* valvar = NULL; |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1081 if (!value->isRef() && !value->isOut()) { |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1082 // Create a local variable to serve as the value. |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1083 DtoRawVarDeclaration(value); |
745
5761d7e6f628
Tried using DtoDeclarationExp for VarDecls in Statements to fix nesting issues
Christian Kamm <kamm incasoftware de>
parents:
733
diff
changeset
|
1084 valvar = value->ir.irLocal->value; |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1085 } |
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
|
1086 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1087 // what to iterate |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1088 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
|
1089 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
|
1090 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1091 // 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
|
1092 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
|
1093 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
|
1094 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1095 if (niters->getType() != keytype) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1096 { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
1097 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
|
1098 size_t sz2 = getTypeBitSize(keytype); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1099 if (sz1 < sz2) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1100 niters = gIR->ir->CreateZExt(niters, keytype, "foreachtrunckey"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1101 else if (sz1 > sz2) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1102 niters = gIR->ir->CreateTrunc(niters, keytype, "foreachtrunckey"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1103 else |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1104 niters = gIR->ir->CreateBitCast(niters, keytype, "foreachtrunckey"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1105 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1106 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1107 LLConstant* delta = 0; |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1108 if (op == TOKforeach) { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1109 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
|
1110 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1111 else { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1112 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
|
1113 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1114 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1115 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1116 llvm::BasicBlock* condbb = llvm::BasicBlock::Create(gIR->context(), "foreachcond", p->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1117 llvm::BasicBlock* bodybb = llvm::BasicBlock::Create(gIR->context(), "foreachbody", p->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1118 llvm::BasicBlock* nextbb = llvm::BasicBlock::Create(gIR->context(), "foreachnext", p->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1119 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "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
|
1120 |
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
|
1121 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
|
1122 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1123 // condition |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1124 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
|
1125 |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1126 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
|
1127 LLValue* load = DtoLoad(keyvar); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1128 if (op == TOKforeach) { |
365 | 1129 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
|
1130 } |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1131 else if (op == TOKforeach_reverse) { |
365 | 1132 done = p->ir->CreateICmpUGT(load, zerokey, "tmp"); |
1554
d6e8d5db259f
LLVMContext changes up to r77366
Benjamin Kramer <benny.kra@gmail.com>
parents:
1549
diff
changeset
|
1133 load = p->ir->CreateSub(load, LLConstantInt::get(keytype, 1, false), "tmp"); |
365 | 1134 DtoStore(load, keyvar); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1135 } |
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
|
1136 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
|
1137 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
1138 // init body |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1139 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
|
1140 |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
1141 // get value for this iteration |
1554
d6e8d5db259f
LLVMContext changes up to r77366
Benjamin Kramer <benny.kra@gmail.com>
parents:
1549
diff
changeset
|
1142 LLConstant* zero = LLConstantInt::get(keytype,0,false); |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1143 LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp"); |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1144 LLValue* gep = DtoGEP1(val,loadedKey); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
1145 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
1146 if (!value->isRef() && !value->isOut()) { |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1147 // Copy value to local variable, and use it as the value variable. |
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
|
1148 DVarValue dst(value->type, valvar); |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1149 DVarValue src(value->type, gep); |
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
|
1150 DtoAssign(loc, &dst, &src); |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
163
diff
changeset
|
1151 value->ir.irLocal->value = valvar; |
1185
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1152 } else { |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1153 // Use the GEP as the address of the value variable. |
8baf611f0009
Fix nested references to 'ref' foreach variables.
Frits van Bommel <fvbommel wxs.nl>
parents:
1160
diff
changeset
|
1154 DtoRawVarDeclaration(value, gep); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
1155 } |
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
|
1156 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
1157 // emit body |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1158 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,nextbb,endbb)); |
519
bc0835cd3440
Don't assert on empty foreach body.
Christian Kamm <kamm incasoftware de>
parents:
518
diff
changeset
|
1159 if(body) |
bc0835cd3440
Don't assert on empty foreach body.
Christian Kamm <kamm incasoftware de>
parents:
518
diff
changeset
|
1160 body->toIR(p); |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1161 p->func()->gen->targetScopes.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
|
1162 |
40 | 1163 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
|
1164 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
|
1165 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1166 // next |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1167 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
|
1168 if (op == TOKforeach) { |
213
7816aafeea3c
[svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents:
206
diff
changeset
|
1169 LLValue* load = DtoLoad(keyvar); |
1554
d6e8d5db259f
LLVMContext changes up to r77366
Benjamin Kramer <benny.kra@gmail.com>
parents:
1549
diff
changeset
|
1170 load = p->ir->CreateAdd(load, LLConstantInt::get(keytype, 1, false), "tmp"); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1171 DtoStore(load, keyvar); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1172 } |
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
|
1173 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
|
1174 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1175 // 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
|
1176 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
|
1177 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1178 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1179 ////////////////////////////////////////////////////////////////////////////// |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
1180 |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1181 #if DMDV2 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1182 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1183 void ForeachRangeStatement::toIR(IRState* p) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1184 { |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1185 Logger::println("ForeachRangeStatement::toIR(): %s", loc.toChars()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1186 LOG_SCOPE; |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1187 |
1650 | 1188 #ifndef DISABLE_DEBUG_INFO |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1189 if (global.params.symdebug) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1190 DtoDwarfStopPoint(loc.linnum); |
1650 | 1191 #endif |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1192 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1193 // evaluate lwr/upr |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1194 assert(lwr->type->isintegral()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1195 LLValue* lower = lwr->toElem(p)->getRVal(); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1196 assert(upr->type->isintegral()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1197 LLValue* upper = upr->toElem(p)->getRVal(); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1198 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1199 // handle key |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1200 assert(key->type->isintegral()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1201 LLValue* keyval = DtoRawVarDeclaration(key); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1202 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1203 // store initial value in key |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1204 if (op == TOKforeach) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1205 DtoStore(lower, keyval); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1206 else |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1207 DtoStore(upper, keyval); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1208 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1209 // set up the block we'll need |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1210 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1211 llvm::BasicBlock* condbb = llvm::BasicBlock::Create(gIR->context(), "foreachrange_cond", p->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1212 llvm::BasicBlock* bodybb = llvm::BasicBlock::Create(gIR->context(), "foreachrange_body", p->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1213 llvm::BasicBlock* nextbb = llvm::BasicBlock::Create(gIR->context(), "foreachrange_next", p->topfunc(), oldend); |
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1214 llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "foreachrange_end", p->topfunc(), oldend); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1215 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1216 // jump to condition |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1217 llvm::BranchInst::Create(condbb, p->scopebb()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1218 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1219 // CONDITION |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1220 p->scope() = IRScope(condbb,bodybb); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1221 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1222 // first we test that lwr < upr |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1223 lower = DtoLoad(keyval); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1224 assert(lower->getType() == upper->getType()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1225 llvm::ICmpInst::Predicate cmpop; |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1226 if (key->type->isunsigned()) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1227 { |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1228 cmpop = (op == TOKforeach) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1229 ? llvm::ICmpInst::ICMP_ULT |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1230 : llvm::ICmpInst::ICMP_UGT; |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1231 } |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1232 else |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1233 { |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1234 cmpop = (op == TOKforeach) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1235 ? llvm::ICmpInst::ICMP_SLT |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1236 : llvm::ICmpInst::ICMP_SGT; |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1237 } |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1238 LLValue* cond = p->ir->CreateICmp(cmpop, lower, upper); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1239 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1240 // jump to the body if range is ok, to the end if not |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1241 llvm::BranchInst::Create(bodybb, endbb, cond, p->scopebb()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1242 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1243 // BODY |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1244 p->scope() = IRScope(bodybb,nextbb); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1245 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1246 // reverse foreach decrements here |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1247 if (op == TOKforeach_reverse) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1248 { |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1249 LLValue* v = DtoLoad(keyval); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1250 LLValue* one = LLConstantInt::get(v->getType(), 1, false); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1251 v = p->ir->CreateSub(v, one); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1252 DtoStore(v, keyval); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1253 } |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1254 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1255 // emit body |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1256 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,nextbb,endbb)); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1257 if (body) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1258 body->toIR(p); |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1259 p->func()->gen->targetScopes.pop_back(); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1260 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1261 // jump to next iteration |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1262 if (!p->scopereturned()) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1263 llvm::BranchInst::Create(nextbb, p->scopebb()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1264 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1265 // NEXT |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1266 p->scope() = IRScope(nextbb,endbb); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1267 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1268 // forward foreach increments here |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1269 if (op == TOKforeach) |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1270 { |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1271 LLValue* v = DtoLoad(keyval); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1272 LLValue* one = LLConstantInt::get(v->getType(), 1, false); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1273 v = p->ir->CreateAdd(v, one); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1274 DtoStore(v, keyval); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1275 } |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1276 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1277 // jump to condition |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1278 llvm::BranchInst::Create(condbb, p->scopebb()); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1279 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1280 // END |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1281 p->scope() = IRScope(endbb,oldend); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1282 } |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1283 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1284 #endif // D2 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1285 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1286 ////////////////////////////////////////////////////////////////////////////// |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1287 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1288 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
|
1289 { |
132 | 1290 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
|
1291 LOG_SCOPE; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1292 |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1293 // 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
|
1294 if (p->asmBlock) |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1295 { |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1296 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
|
1297 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
|
1298 a->code += "_"; |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1299 a->code += ident->toChars(); |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1300 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
|
1301 p->asmBlock->s.push_back(a); |
299
df8a7b8d5929
[svn r320] Begun work on branches out of asm blocks. Unfinished.
ChristianK
parents:
298
diff
changeset
|
1302 p->asmBlock->internalLabels.push_back(ident); |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1303 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1304 // disable inlining |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1305 gIR->func()->setNeverInline(); |
298
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1306 } |
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1307 else |
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1308 { |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1309 std::string labelname = p->func()->gen->getScopedLabelName(ident->toChars()); |
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1310 llvm::BasicBlock*& labelBB = p->func()->gen->labelToBB[labelname]; |
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
|
1311 |
298
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1312 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
|
1313 if (labelBB != NULL) { |
980
ae710cba0884
Clean up the code generated when jumping out of inline asm and make label names more expressive.
Frits van Bommel <fvbommel wxs.nl>
parents:
976
diff
changeset
|
1314 labelBB->moveBefore(oldend); |
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
|
1315 } else { |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1316 labelBB = llvm::BasicBlock::Create(gIR->context(), "label_" + labelname, p->topfunc(), oldend); |
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
|
1317 } |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
1318 |
298
3b8ada4c9f8b
[svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents:
271
diff
changeset
|
1319 if (!p->scopereturned()) |
980
ae710cba0884
Clean up the code generated when jumping out of inline asm and make label names more expressive.
Frits van Bommel <fvbommel wxs.nl>
parents:
976
diff
changeset
|
1320 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
|
1321 |
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
|
1322 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
|
1323 } |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
1324 |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
1325 if (statement) { |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1326 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,NULL,NULL)); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
1327 statement->toIR(p); |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1328 p->func()->gen->targetScopes.pop_back(); |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
1329 } |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1330 } |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1331 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1332 ////////////////////////////////////////////////////////////////////////////// |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1333 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1334 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
|
1335 { |
132 | 1336 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
|
1337 LOG_SCOPE; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1338 |
1650 | 1339 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1340 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1341 DtoDwarfStopPoint(loc.linnum); |
1650 | 1342 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1343 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1344 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1345 llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "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
|
1346 |
1160
7d28dcbff23e
Reenable error for gotos into or out of finally blocks.
Christian Kamm <kamm incasoftware de>
parents:
1145
diff
changeset
|
1347 DtoGoto(loc, label->ident, enclosingFinally); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1348 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1349 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
|
1350 } |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1351 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1352 ////////////////////////////////////////////////////////////////////////////// |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1353 |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1354 void GotoDefaultStatement::toIR(IRState* p) |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1355 { |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1356 Logger::println("GotoDefaultStatement::toIR(): %s", loc.toChars()); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1357 LOG_SCOPE; |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1358 |
1650 | 1359 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1360 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1361 DtoDwarfStopPoint(loc.linnum); |
1650 | 1362 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1363 |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1364 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1365 llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftergotodefault", p->topfunc(), oldend); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1366 |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1367 assert(!p->scopereturned()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1368 assert(sw->sdefault->bodyBB); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1369 |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
1370 DtoEnclosingHandlers(loc, sw); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1371 |
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
|
1372 llvm::BranchInst::Create(sw->sdefault->bodyBB, p->scopebb()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1373 p->scope() = IRScope(bb,oldend); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1374 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1375 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1376 ////////////////////////////////////////////////////////////////////////////// |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1377 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1378 void GotoCaseStatement::toIR(IRState* p) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1379 { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1380 Logger::println("GotoCaseStatement::toIR(): %s", loc.toChars()); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1381 LOG_SCOPE; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1382 |
1650 | 1383 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1384 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1385 DtoDwarfStopPoint(loc.linnum); |
1650 | 1386 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1387 |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1388 llvm::BasicBlock* oldend = gIR->scopeend(); |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1389 llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftergotocase", p->topfunc(), oldend); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1390 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1391 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
|
1392 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
|
1393 { |
1571
8d086d552909
IntegerType is now contextifed.
Benjamin Kramer <benny.kra@gmail.com>
parents:
1569
diff
changeset
|
1394 cs->bodyBB = llvm::BasicBlock::Create(gIR->context(), "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
|
1395 } |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1396 |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
1397 DtoEnclosingHandlers(loc, sw); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1398 |
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
|
1399 llvm::BranchInst::Create(cs->bodyBB, p->scopebb()); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1400 p->scope() = IRScope(bb,oldend); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1401 } |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1402 |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1403 ////////////////////////////////////////////////////////////////////////////// |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1404 |
40 | 1405 void WithStatement::toIR(IRState* p) |
1406 { | |
132 | 1407 Logger::println("WithStatement::toIR(): %s", loc.toChars()); |
40 | 1408 LOG_SCOPE; |
1409 | |
1650 | 1410 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1411 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1412 DtoDwarfStopPoint(loc.linnum); |
1650 | 1413 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1414 |
40 | 1415 assert(exp); |
1416 assert(body); | |
1417 | |
831
7e59caf41433
Fix with(symbol) statement.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1418 // with(..) can either be used with expressions or with symbols |
7e59caf41433
Fix with(symbol) statement.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1419 // wthis == null indicates the symbol form |
7e59caf41433
Fix with(symbol) statement.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1420 if (wthis) { |
7e59caf41433
Fix with(symbol) statement.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1421 DValue* e = exp->toElem(p); |
7e59caf41433
Fix with(symbol) statement.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1422 LLValue* mem = DtoRawVarDeclaration(wthis); |
7e59caf41433
Fix with(symbol) statement.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1423 DtoStore(e->getRVal(), mem); |
7e59caf41433
Fix with(symbol) statement.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
1424 } |
40 | 1425 |
1426 body->toIR(p); | |
1427 } | |
1428 | |
1429 ////////////////////////////////////////////////////////////////////////////// | |
1430 | |
309 | 1431 static LLConstant* generate_unique_critical_section() |
1432 { | |
1433 const LLType* Mty = DtoMutexType(); | |
1560
1d5c3354b3c2
getNullValue is in Constant again
Benjamin Kramer <benny.kra@gmail.com>
parents:
1554
diff
changeset
|
1434 return new llvm::GlobalVariable(*gIR->module, Mty, false, llvm::GlobalValue::InternalLinkage, LLConstant::getNullValue(Mty), ".uniqueCS"); |
309 | 1435 } |
1436 | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1437 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
|
1438 { |
132 | 1439 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
|
1440 LOG_SCOPE; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1441 |
1650 | 1442 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1443 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1444 DtoDwarfStopPoint(loc.linnum); |
1650 | 1445 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1446 |
309 | 1447 // enter lock |
1448 if (exp) | |
1449 { | |
1450 llsync = exp->toElem(p)->getRVal(); | |
1451 DtoEnterMonitor(llsync); | |
1452 } | |
1453 else | |
1454 { | |
1455 llsync = generate_unique_critical_section(); | |
1456 DtoEnterCritical(llsync); | |
1457 } | |
1458 | |
1459 // emit body | |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1460 p->func()->gen->targetScopes.push_back(IRTargetScope(this,new EnclosingSynchro(this),NULL,NULL)); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1461 body->toIR(p); |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1462 p->func()->gen->targetScopes.pop_back(); |
309 | 1463 |
1464 // exit lock | |
1465 // no point in a unreachable unlock, terminating statements must insert this themselves. | |
1466 if (p->scopereturned()) | |
1467 return; | |
1468 else if (exp) | |
1469 DtoLeaveMonitor(llsync); | |
1470 else | |
1471 DtoLeaveCritical(llsync); | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1472 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1473 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1474 ////////////////////////////////////////////////////////////////////////////// |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1475 |
132 | 1476 void VolatileStatement::toIR(IRState* p) |
1477 { | |
1478 Logger::println("VolatileStatement::toIR(): %s", loc.toChars()); | |
1479 LOG_SCOPE; | |
1480 | |
1650 | 1481 #ifndef DISABLE_DEBUG_INFO |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1482 if (global.params.symdebug) |
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1483 DtoDwarfStopPoint(loc.linnum); |
1650 | 1484 #endif |
268
23d0d9855cad
[svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents:
267
diff
changeset
|
1485 |
206 | 1486 // mark in-volatile |
309 | 1487 // 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
|
1488 |
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
|
1489 // 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
|
1490 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
|
1491 { |
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
|
1492 // 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
|
1493 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
|
1494 |
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
|
1495 // do statement |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1496 p->func()->gen->targetScopes.push_back(IRTargetScope(this,new EnclosingVolatile(this),NULL,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
|
1497 statement->toIR(p); |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1414
diff
changeset
|
1498 p->func()->gen->targetScopes.pop_back(); |
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
|
1499 |
309 | 1500 // no point in a unreachable barrier, terminating statements must insert this themselves. |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
831
diff
changeset
|
1501 if (statement->blockExit() & BEfallthru) |
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
|
1502 { |
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
|
1503 // 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
|
1504 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
|
1505 } |
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
|
1506 } |
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
|
1507 // 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
|
1508 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
|
1509 { |
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
|
1510 // 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
|
1511 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
|
1512 } |
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
|
1513 |
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
|
1514 // restore volatile state |
309 | 1515 // FIXME |
132 | 1516 } |
1517 | |
1518 ////////////////////////////////////////////////////////////////////////////// | |
1519 | |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1520 void SwitchErrorStatement::toIR(IRState* p) |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1521 { |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1522 Logger::println("SwitchErrorStatement::toIR(): %s", loc.toChars()); |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1523 LOG_SCOPE; |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1524 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1525 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_switch_error"); |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1526 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1527 std::vector<LLValue*> args; |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1528 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1529 // file param |
1271
0686701178d3
Moved special casing of 'assert(this, "null this");' generated statements from !ThisExp into !AssertExp.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1185
diff
changeset
|
1530 IrModule* irmod = getIrModule(NULL); |
0686701178d3
Moved special casing of 'assert(this, "null this");' generated statements from !ThisExp into !AssertExp.
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1185
diff
changeset
|
1531 args.push_back(DtoLoad(irmod->fileName)); |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1532 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1533 // line param |
683
b411c41a9716
Only allocate the module file name once. Fixes #90.
Christian Kamm <kamm incasoftware de>
parents:
652
diff
changeset
|
1534 LLConstant* c = DtoConstUint(loc.linnum); |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1535 args.push_back(c); |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1536 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1537 // call |
1013
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
994
diff
changeset
|
1538 gIR->CreateCallOrInvoke(fn, args.begin(), args.end()); |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1539 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1540 gIR->ir->CreateUnreachable(); |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1541 } |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1542 |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1543 ////////////////////////////////////////////////////////////////////////////// |
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1544 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1545 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1546 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1547 #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
|
1548 //STUBST(BreakStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1549 //STUBST(ForStatement); |
40 | 1550 //STUBST(WithStatement); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1551 //STUBST(SynchronizedStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1552 //STUBST(ReturnStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1553 //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
|
1554 //STUBST(DefaultStatement); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
1555 //STUBST(CaseStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1556 //STUBST(SwitchStatement); |
331
04e1b4930975
[svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents:
319
diff
changeset
|
1557 //STUBST(SwitchErrorStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1558 STUBST(Statement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1559 //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
|
1560 //STUBST(ForeachStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1561 //STUBST(DoStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1562 //STUBST(WhileStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1563 //STUBST(ExpStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1564 //STUBST(CompoundStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1565 //STUBST(ScopeStatement); |
131 | 1566 //STUBST(AsmStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1567 //STUBST(TryCatchStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1568 //STUBST(TryFinallyStatement); |
132 | 1569 //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
|
1570 //STUBST(LabelStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1571 //STUBST(ThrowStatement); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1572 //STUBST(GotoCaseStatement); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1573 //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
|
1574 //STUBST(GotoStatement); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1575 //STUBST(UnrolledLoopStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1576 //STUBST(OnScopeStatement); |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1577 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1578 #if DMDV2 |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1579 STUBST(PragmaStatement); |
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
747
diff
changeset
|
1580 #endif |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1581 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1582 ////////////////////////////////////////////////////////////////////////////// |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1583 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1584 ////////////////////////////////////////////////////////////////////////////// |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1585 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1586 AsmBlockStatement* Statement::endsWithAsm() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1587 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1588 // does not end with inline asm |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1589 return NULL; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1590 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1591 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1592 AsmBlockStatement* CompoundStatement::endsWithAsm() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1593 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1594 // make the last inner statement decide |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1595 if (statements && statements->dim) |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1596 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1597 unsigned last = statements->dim - 1; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1598 Statement* s = (Statement*)statements->data[last]; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1599 if (s) return s->endsWithAsm(); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1600 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1601 return NULL; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1602 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1603 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1604 AsmBlockStatement* AsmBlockStatement::endsWithAsm() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1605 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1606 // yes this is inline asm |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1607 return this; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
1608 } |