annotate gen/statements.cpp @ 121:9c79b61fb638 trunk

[svn r125] Renamed/moved a few backend member inside DMD structures for consistency. Unit tests are now implemented.
author lindquist
date Tue, 27 Nov 2007 03:09:36 +0100
parents 5ab8e92611f9
children 36ab367572df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1 // Statements: D -> LLVM glue
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
2
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
3 #include <stdio.h>
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
4 #include <math.h>
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
5 #include <sstream>
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
6 #include <fstream>
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
7 #include <iostream>
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
8
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
9 #include "gen/llvm.h"
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
10
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
11 #include "total.h"
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"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
16
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
17 #include "gen/irstate.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
18 #include "gen/logger.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
19 #include "gen/tollvm.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
20 #include "gen/runtime.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
21 #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
22 #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
23 #include "gen/dvalue.h"
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
24
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
25 //////////////////////////////////////////////////////////////////////////////
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
26
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
27 void CompoundStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
28 {
98
6789050b5ad1 [svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents: 96
diff changeset
29 Logger::println("CompoundStatement::toIR()");
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
30 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
31
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
32 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
33 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
34 Statement* s = (Statement*)statements->data[i];
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
35 if (s)
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
36 s->toIR(p);
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
37 else {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
38 Logger::println("??? null statement found in CompoundStatement");
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
39 }
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 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
42
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
43 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
44
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
45 void ReturnStatement::toIR(IRState* p)
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 static int rsi = 0;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
48 Logger::println("ReturnStatement::toIR(%d): %s", rsi++, toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
49 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
50
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
51 if (exp)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
52 {
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 51
diff changeset
53 Logger::println("return type is: %s", exp->type->toChars());
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 51
diff changeset
54
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
55 Type* exptype = DtoDType(exp->type);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
56 TY expty = exptype->ty;
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
57 if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) {
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
58 assert(DtoIsPassedByRef(exptype));
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
59
121
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 109
diff changeset
60 IRFunction* f = p->func();
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 109
diff changeset
61 assert(f->type->llvmRetInPtr);
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 109
diff changeset
62 assert(f->decl->llvmRetArg);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
63
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
64 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum);
d8dd47ef3973 [svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents: 81
diff changeset
65
121
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 109
diff changeset
66 DValue* rvar = new DVarValue(f->type->next, f->decl->llvmRetArg, true);
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
67
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
68 p->exps.push_back(IRExp(NULL,exp,rvar));
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
69 DValue* e = exp->toElem(p);
54
28e99b04a132 [svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents: 51
diff changeset
70 p->exps.pop_back();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
71
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
72 if (!e->inPlace())
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
73 DtoAssign(rvar, e);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
74
121
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 109
diff changeset
75 IRFunction::FinallyVec& fin = f->finallys;
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
76 if (fin.empty()) {
121
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 109
diff changeset
77 if (global.params.symdebug) DtoDwarfFuncEnd(f->decl);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
78 new llvm::ReturnInst(p->scopebb());
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
79 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
80 else {
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
81 new llvm::BranchInst(fin.back().retbb, p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
82 }
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
83 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
84 else {
82
d8dd47ef3973 [svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents: 81
diff changeset
85 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum);
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
86 DValue* e = exp->toElem(p);
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
87 llvm::Value* v = e->getRVal();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
88 delete e;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
89 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
90
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
91 IRFunction::FinallyVec& fin = p->func()->finallys;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
92 if (fin.empty()) {
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
93 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
94 new llvm::ReturnInst(v, p->scopebb());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
95 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
96 else {
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
97 if (!p->func()->finallyretval)
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
98 p->func()->finallyretval = new llvm::AllocaInst(v->getType(),"tmpreturn",p->topallocapoint());
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
99 llvm::Value* rettmp = p->func()->finallyretval;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
100 new llvm::StoreInst(v,rettmp,p->scopebb());
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
101 new llvm::BranchInst(fin.back().retbb, p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
102 }
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
103 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
104 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
105 else
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
106 {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
107 if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) {
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
108 IRFunction::FinallyVec& fin = p->func()->finallys;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
109 if (fin.empty()) {
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
110 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
111 new llvm::ReturnInst(p->scopebb());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
112 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
113 else {
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
114 new llvm::BranchInst(fin.back().retbb, p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
115 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
116 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
117 else {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
118 assert(0); // why should this ever happen?
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
119 new llvm::UnreachableInst(p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
120 }
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
121 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
122 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
123
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
124 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
125
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
126 void ExpStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
127 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
128 static int esi = 0;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
129 Logger::println("ExpStatement::toIR(%d): %s", esi++, toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
130 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
131
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
132 if (global.params.symdebug)
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
133 DtoDwarfStopPoint(loc.linnum);
82
d8dd47ef3973 [svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents: 81
diff changeset
134
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
135 if (exp != 0) {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
136 elem* e = exp->toElem(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
137 delete e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
138 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
139 /*elem* e = exp->toElem(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
140 p->buf.printf("%s", e->toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
141 delete e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
142 p->buf.writenl();*/
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
143 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
144
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
145 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
146
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
147 void IfStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
148 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
149 static int wsi = 0;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
150 Logger::println("IfStatement::toIR(%d): %s", wsi++, toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
151 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
152
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
153 DValue* cond_e = condition->toElem(p);
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
154 llvm::Value* cond_val = cond_e->getRVal();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
155 delete cond_e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
156
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
157 llvm::BasicBlock* oldend = gIR->scopeend();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
158
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
159 llvm::BasicBlock* ifbb = new llvm::BasicBlock("if", gIR->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
160 llvm::BasicBlock* endbb = new llvm::BasicBlock("endif", gIR->topfunc(), oldend);
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
161 llvm::BasicBlock* elsebb = elsebody ? new llvm::BasicBlock("else", gIR->topfunc(), endbb) : endbb;
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
162
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
163 if (cond_val->getType() != llvm::Type::Int1Ty) {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
164 Logger::cout() << "if conditional: " << *cond_val << '\n';
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
165 cond_val = DtoBoolean(cond_val);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
166 }
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
167 llvm::Value* ifgoback = new llvm::BranchInst(ifbb, elsebb, cond_val, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
168
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
169 // replace current scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
170 gIR->scope() = IRScope(ifbb,elsebb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
171
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
172 // do scoped statements
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
173 ifbody->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
174 if (!gIR->scopereturned()) {
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
175 new llvm::BranchInst(endbb,gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
176 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
177
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
178 if (elsebody) {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
179 //assert(0);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
180 gIR->scope() = IRScope(elsebb,endbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
181 elsebody->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
182 if (!gIR->scopereturned()) {
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
183 new llvm::BranchInst(endbb,gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
184 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
185 }
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 // rewrite the scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
188 gIR->scope() = IRScope(endbb,oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
189 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
190
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
191 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
192
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
193 void ScopeStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
194 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
195 Logger::println("ScopeStatement::toIR(): %s", toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
196 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
197
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
198 llvm::BasicBlock* oldend = p->scopeend();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
199
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
200 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
201
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
202 // 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
203 llvm::BasicBlock* bb = p->scopebb();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
204 if (bb->empty()) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
205 beginbb = bb;
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
206 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
207 else {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
208 assert(!p->scopereturned());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
209 beginbb = new llvm::BasicBlock("scope", p->topfunc(), oldend);
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
210 new llvm::BranchInst(beginbb, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
211 }
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
212 llvm::BasicBlock* endbb = new llvm::BasicBlock("endscope", p->topfunc(), oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
213
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
214 gIR->scope() = IRScope(beginbb, endbb);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
215
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
216 statement->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
217
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
218 p->scope() = IRScope(p->scopebb(),oldend);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
219 endbb->eraseFromParent();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
220 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
221
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
222 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
223
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
224 void WhileStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
225 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
226 static int wsi = 0;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
227 Logger::println("WhileStatement::toIR(%d): %s", wsi++, toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
228 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
229
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
230 // create while blocks
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
231 llvm::BasicBlock* oldend = gIR->scopeend();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
232 llvm::BasicBlock* whilebb = new llvm::BasicBlock("whilecond", gIR->topfunc(), oldend);
78
2332006e1fa4 [svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents: 73
diff changeset
233 llvm::BasicBlock* whilebodybb = new llvm::BasicBlock("whilebody", gIR->topfunc(), oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
234 llvm::BasicBlock* endbb = new llvm::BasicBlock("endwhile", gIR->topfunc(), oldend);
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 // move into the while block
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
237 p->ir->CreateBr(whilebb);
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
238 //new llvm::BranchInst(whilebb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
239
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
240 // replace current scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
241 gIR->scope() = IRScope(whilebb,endbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
242
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
243 // create the condition
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
244 DValue* cond_e = condition->toElem(p);
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
245 llvm::Value* cond_val = DtoBoolean(cond_e->getRVal());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
246 delete cond_e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
247
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
248 // conditional branch
78
2332006e1fa4 [svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents: 73
diff changeset
249 llvm::Value* ifbreak = new llvm::BranchInst(whilebodybb, endbb, cond_val, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
250
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
251 // rewrite scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
252 gIR->scope() = IRScope(whilebodybb,endbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
253
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
254 // while body code
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
255 p->loopbbs.push_back(IRScope(whilebb,endbb));
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
256 body->toIR(p);
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
257 p->loopbbs.pop_back();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
258
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
259 // loop
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
260 if (!gIR->scopereturned())
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
261 new llvm::BranchInst(whilebb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
262
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
263 // rewrite the scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
264 gIR->scope() = IRScope(endbb,oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
265 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
266
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
267 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
268
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
269 void DoStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
270 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
271 static int wsi = 0;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
272 Logger::println("DoStatement::toIR(%d): %s", wsi++, toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
273 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
274
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
275 // create while blocks
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
276 llvm::BasicBlock* oldend = gIR->scopeend();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
277 llvm::BasicBlock* dowhilebb = new llvm::BasicBlock("dowhile", gIR->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
278 llvm::BasicBlock* endbb = new llvm::BasicBlock("enddowhile", gIR->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
279
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
280 // move into the while block
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
281 assert(!gIR->scopereturned());
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
282 new llvm::BranchInst(dowhilebb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
283
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
284 // replace current scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
285 gIR->scope() = IRScope(dowhilebb,endbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
286
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
287 // do-while body code
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
288 p->loopbbs.push_back(IRScope(dowhilebb,endbb));
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
289 body->toIR(p);
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
290 p->loopbbs.pop_back();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
291
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
292 // create the condition
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
293 DValue* cond_e = condition->toElem(p);
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
294 llvm::Value* cond_val = DtoBoolean(cond_e->getRVal());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
295 delete cond_e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
296
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
297 // conditional branch
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
298 llvm::Value* ifbreak = new llvm::BranchInst(dowhilebb, endbb, cond_val, 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 // rewrite the scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
301 gIR->scope() = IRScope(endbb,oldend);
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
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
304 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
305
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
306 void ForStatement::toIR(IRState* p)
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 static int wsi = 0;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
309 Logger::println("ForStatement::toIR(%d): %s", wsi++, toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
310 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
311
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
312 // create for blocks
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
313 llvm::BasicBlock* oldend = gIR->scopeend();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
314 llvm::BasicBlock* forbb = new llvm::BasicBlock("forcond", gIR->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
315 llvm::BasicBlock* forbodybb = new llvm::BasicBlock("forbody", gIR->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
316 llvm::BasicBlock* forincbb = new llvm::BasicBlock("forinc", gIR->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
317 llvm::BasicBlock* endbb = new llvm::BasicBlock("endfor", gIR->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
318
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
319 // init
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
320 if (init != 0)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
321 init->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
322
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
323 // move into the for condition block, ie. start the loop
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
324 new llvm::BranchInst(forbb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
325
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
326 p->loopbbs.push_back(IRScope(forincbb,endbb));
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
327
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
328 // replace current scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
329 gIR->scope() = IRScope(forbb,forbodybb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
330
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
331 // create the condition
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
332 DValue* cond_e = condition->toElem(p);
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
333 llvm::Value* cond_val = DtoBoolean(cond_e->getRVal());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
334 delete cond_e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
335
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
336 // conditional branch
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
337 llvm::Value* ifbreak = new llvm::BranchInst(forbodybb, endbb, cond_val, forbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
338
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
339 // rewrite scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
340 gIR->scope() = IRScope(forbodybb,forincbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
341
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
342 // do for body code
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
343 body->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
344
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
345 // move into the for increment block
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
346 if (!gIR->scopereturned())
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
347 new llvm::BranchInst(forincbb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
348 gIR->scope() = IRScope(forincbb, endbb);
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 // increment
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
351 if (increment) {
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
352 DValue* inc = increment->toElem(p);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
353 delete inc;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
354 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
355
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
356 // loop
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
357 if (!gIR->scopereturned())
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
358 new llvm::BranchInst(forbb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
359
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
360 p->loopbbs.pop_back();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
361
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
362 // rewrite the scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
363 gIR->scope() = IRScope(endbb,oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
364 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
365
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
366 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
367
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
368 void BreakStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
369 {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
370 Logger::println("BreakStatement::toIR(): %s", toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
371 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
372
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
373 if (ident != 0) {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
374 Logger::println("ident = %s", ident->toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
375 assert(0);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
376 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
377 else {
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
378 new llvm::BranchInst(gIR->loopbbs.back().end, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
379 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
380 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
381
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
382 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
383
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
384 void ContinueStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
385 {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
386 Logger::println("ContinueStatement::toIR(): %s", toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
387 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
388
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
389 if (ident != 0) {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
390 Logger::println("ident = %s", ident->toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
391 assert(0);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
392 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
393 else {
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
394 new llvm::BranchInst(gIR->loopbbs.back().begin, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
395 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
396 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
397
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
398 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
399
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
400 void OnScopeStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
401 {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
402 Logger::println("OnScopeStatement::toIR(): %s", toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
403 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
404
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
405 assert(statement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
406 //statement->toIR(p); // this seems to be redundant
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
407 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
408
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
409 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
410
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
411 void TryFinallyStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
412 {
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
413 Logger::println("TryFinallyStatement::toIR(): %s", toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
414 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
415
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
416 // create basic blocks
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
417 llvm::BasicBlock* oldend = p->scopeend();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
418
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
419 llvm::BasicBlock* trybb = new llvm::BasicBlock("try", p->topfunc(), oldend);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
420 llvm::BasicBlock* finallybb = new llvm::BasicBlock("finally", p->topfunc(), oldend);
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
421 llvm::BasicBlock* finallyretbb = new llvm::BasicBlock("finallyreturn", p->topfunc(), oldend);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
422 llvm::BasicBlock* endbb = new llvm::BasicBlock("endtryfinally", p->topfunc(), oldend);
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 // 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
425 assert(!gIR->scopereturned());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
426 new llvm::BranchInst(trybb, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
427
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
428 // do the try block
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
429 p->scope() = IRScope(trybb,finallybb);
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
430 gIR->func()->finallys.push_back(IRFinally(finallybb,finallyretbb));
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
431 IRFinally& fin = p->func()->finallys.back();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
432
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
433 assert(body);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
434 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
435
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
436 // 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
437 if (!p->scopereturned())
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
438 new llvm::BranchInst(finallybb, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
439
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
440 // do finally block
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
441 p->scope() = IRScope(finallybb,finallyretbb);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
442 assert(finalbody);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
443 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
444
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
445 // terminate finally
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
446 if (!gIR->scopereturned()) {
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
447 new llvm::BranchInst(endbb, p->scopebb());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
448 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
449
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
450 // do finally block (return path)
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
451 p->scope() = IRScope(finallyretbb,endbb);
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
452 assert(finalbody);
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
453 finalbody->toIR(p); // hope this will work, otherwise it's time it gets fixed
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
454
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
455 // terminate finally (return path)
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
456 size_t nfin = p->func()->finallys.size();
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
457 if (nfin > 1) {
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
458 IRFinally& ofin = p->func()->finallys[nfin-2];
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
459 p->ir->CreateBr(ofin.retbb);
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
460 }
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
461 // no outer
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
462 else
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
463 {
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
464 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
465 llvm::Value* retval = p->func()->finallyretval;
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
466 if (retval) {
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
467 retval = p->ir->CreateLoad(retval,"tmp");
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
468 p->ir->CreateRet(retval);
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
469 }
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
470 else {
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
471 FuncDeclaration* fd = p->func()->decl;
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
472 if (fd->isMain()) {
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
473 assert(fd->type->next->ty == Tvoid);
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
474 p->ir->CreateRet(DtoConstInt(0));
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
475 }
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
476 else {
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
477 p->ir->CreateRetVoid();
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
478 }
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
479 }
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
480 }
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
481
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
482 // rewrite the scope
100
5071469303d4 [svn r104] TONS OF FIXES.
lindquist
parents: 98
diff changeset
483 p->func()->finallys.pop_back();
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
484 p->scope() = IRScope(endbb,oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
485 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
486
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
487 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
488
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
489 void TryCatchStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
490 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
491 static int wsi = 0;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
492 Logger::println("TryCatchStatement::toIR(%d): %s", wsi++, toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
493 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
494
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
495 Logger::attention("try-catch is not yet fully implemented, only the try block will be emitted.");
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
496
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
497 assert(body);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
498 body->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
499
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
500 /*assert(catches);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
501 for(size_t i=0; i<catches->dim; ++i)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
502 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
503 Catch* c = (Catch*)catches->data[i];
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
504 c->handler->toIR(p);
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
505 }*/
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
506 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
507
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
508 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
509
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
510 void ThrowStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
511 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
512 static int wsi = 0;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
513 Logger::println("ThrowStatement::toIR(%d): %s", wsi++, toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
514 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
515
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
516 Logger::attention("throw is not yet implemented, replacing expression with assert(0);");
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
517
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
518 DtoAssert(NULL, &loc, NULL);
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
519
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
520 /*
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
521 assert(exp);
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
522 DValue* e = exp->toElem(p);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
523 delete e;
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
524 */
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
525 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
526
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
527 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
528
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
529 void SwitchStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
530 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
531 Logger::println("SwitchStatement::toIR(): %s", toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
532 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
533
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
534 llvm::BasicBlock* oldend = gIR->scopeend();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
535
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
536 // collect the needed cases
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
537 typedef std::pair<llvm::BasicBlock*, std::vector<llvm::ConstantInt*> > CasePair;
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
538 std::vector<CasePair> vcases;
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
539 std::vector<Statement*> vbodies;
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
540 for (int i=0; i<cases->dim; ++i)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
541 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
542 CaseStatement* cs = (CaseStatement*)cases->data[i];
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
543
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
544 // create the case bb with a nice label
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
545 std::string lblname("case"+std::string(cs->exp->toChars()));
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
546 llvm::BasicBlock* bb = new llvm::BasicBlock(lblname, p->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
547
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
548 std::vector<llvm::ConstantInt*> tmp;
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
549 CaseStatement* last;
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
550 do {
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
551 // get the case value
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
552 DValue* e = cs->exp->toElem(p);
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
553 DConstValue* ce = e->isConst();
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
554 assert(ce);
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
555 llvm::ConstantInt* ec = isaConstantInt(ce->c);
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
556 assert(ec);
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
557 tmp.push_back(ec);
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
558 last = cs;
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
559 }
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
560 while (cs = cs->statement->isCaseStatement());
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
561
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
562 vcases.push_back(CasePair(bb, tmp));
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
563 vbodies.push_back(last->statement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
564 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
565
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
566 // default
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
567 llvm::BasicBlock* defbb = 0;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
568 if (!hasNoDefault) {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
569 defbb = new llvm::BasicBlock("default", p->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
570 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
571
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
572 // end (break point)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
573 llvm::BasicBlock* endbb = new llvm::BasicBlock("switchend", p->topfunc(), oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
574
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
575 // condition var
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
576 DValue* cond = condition->toElem(p);
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
577 llvm::SwitchInst* si = new llvm::SwitchInst(cond->getRVal(), defbb ? defbb : endbb, cases->dim, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
578 delete cond;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
579
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
580 // add the cases
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
581 size_t n = vcases.size();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
582 for (size_t i=0; i<n; ++i)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
583 {
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
584 size_t nc = vcases[i].second.size();
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
585 for (size_t j=0; j<nc; ++j)
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
586 {
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
587 si->addCase(vcases[i].second[j], vcases[i].first);
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
588 }
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
589 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
590
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
591 // insert case statements
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
592 for (size_t i=0; i<n; ++i)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
593 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
594 llvm::BasicBlock* nextbb = (i == n-1) ? (defbb ? defbb : endbb) : vcases[i+1].first;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
595 p->scope() = IRScope(vcases[i].first,nextbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
596
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
597 p->loopbbs.push_back(IRScope(p->scopebb(),endbb));
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
598 vbodies[i]->toIR(p);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
599 p->loopbbs.pop_back();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
600
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
601 llvm::BasicBlock* curbb = p->scopebb();
78
2332006e1fa4 [svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents: 73
diff changeset
602 if (curbb->empty() || !curbb->back().isTerminator())
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
603 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
604 new llvm::BranchInst(nextbb, curbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
605 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
606 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
607
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
608 // default statement
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
609 if (defbb)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
610 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
611 p->scope() = IRScope(defbb,endbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
612 p->loopbbs.push_back(IRScope(defbb,endbb));
78
2332006e1fa4 [svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents: 73
diff changeset
613 Logger::println("doing default statement");
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
614 sdefault->statement->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
615 p->loopbbs.pop_back();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
616
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
617 llvm::BasicBlock* curbb = p->scopebb();
78
2332006e1fa4 [svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents: 73
diff changeset
618 if (curbb->empty() || !curbb->back().isTerminator())
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
619 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
620 new llvm::BranchInst(endbb, curbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
621 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
622 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
623
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
624 gIR->scope() = IRScope(endbb,oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
625 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
626
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
627 //////////////////////////////////////////////////////////////////////////////
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
628 void CaseStatement::toIR(IRState* p)
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
629 {
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
630 Logger::println("CaseStatement::toIR(): %s", toChars());
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
631 LOG_SCOPE;
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
632
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
633 assert(0);
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
634 }
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
635
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
636 //////////////////////////////////////////////////////////////////////////////
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
637
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
638 void UnrolledLoopStatement::toIR(IRState* p)
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
639 {
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
640 Logger::println("UnrolledLoopStatement::toIR(): %s", toChars());
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
641 LOG_SCOPE;
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
642
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
643 llvm::BasicBlock* oldend = gIR->scopeend();
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
644 llvm::BasicBlock* endbb = new llvm::BasicBlock("unrolledend", p->topfunc(), oldend);
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
645
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
646 p->scope() = IRScope(p->scopebb(),endbb);
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
647 p->loopbbs.push_back(IRScope(p->scopebb(),endbb));
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
648
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
649 for (int i=0; i<statements->dim; ++i)
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
650 {
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
651 Statement* s = (Statement*)statements->data[i];
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
652 s->toIR(p);
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
653 }
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
654
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
655 p->loopbbs.pop_back();
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
656
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
657 new llvm::BranchInst(endbb, p->scopebb());
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
658 p->scope() = IRScope(endbb,oldend);
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
659 }
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
660
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
661 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
662
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
663 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
664 {
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
665 Logger::println("ForeachStatement::toIR(): %s", 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
666 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
667
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
668 //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
669 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
670 assert(body != 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
671 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
672 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
673
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
674 //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
675 //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
676
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
677 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
678
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
679 // key
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
680 const llvm::Type* keytype = key ? DtoType(key->type) : DtoSize_t();
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
681 llvm::Value* keyvar = new llvm::AllocaInst(keytype, "foreachkey", p->topallocapoint());
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
682 if (key) key->llvmValue = keyvar;
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
683 llvm::Value* zerokey = llvm::ConstantInt::get(keytype,0,false);
32
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
684
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
685 // value
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
686 const llvm::Type* valtype = DtoType(value->type);
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
687 llvm::Value* valvar = NULL;
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
688 if (!value->isRef() && !value->isOut())
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
689 valvar = new llvm::AllocaInst(valtype, "foreachval", p->topallocapoint());
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
690
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
691 // what to iterate
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
692 DValue* aggrval = aggr->toElem(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
693 Type* aggrtype = DtoDType(aggr->type);
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
694
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
695 // get length and pointer
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
696 llvm::Value* val = 0;
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
697 llvm::Value* niters = 0;
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
698
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
699 // static array
45
ff359b65fa62 [svn r49] foreach on dynamic arrays
lindquist
parents: 40
diff changeset
700 if (aggrtype->ty == Tsarray)
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
701 {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
702 Logger::println("foreach over static array");
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
703 val = aggrval->getRVal();
96
ce7ed8f59b99 [svn r100] Moved test/ray.d to demos/ray.d.
lindquist
parents: 94
diff changeset
704 assert(isaPointer(val->getType()));
ce7ed8f59b99 [svn r100] Moved test/ray.d to demos/ray.d.
lindquist
parents: 94
diff changeset
705 const llvm::ArrayType* arrty = isaArray(val->getType()->getContainedType(0));
ce7ed8f59b99 [svn r100] Moved test/ray.d to demos/ray.d.
lindquist
parents: 94
diff changeset
706 assert(arrty);
ce7ed8f59b99 [svn r100] Moved test/ray.d to demos/ray.d.
lindquist
parents: 94
diff changeset
707 size_t nelems = arrty->getNumElements();
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
708 assert(nelems > 0);
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
709 niters = llvm::ConstantInt::get(keytype,nelems,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
710 }
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
711 // dynamic array
45
ff359b65fa62 [svn r49] foreach on dynamic arrays
lindquist
parents: 40
diff changeset
712 else if (aggrtype->ty == Tarray)
ff359b65fa62 [svn r49] foreach on dynamic arrays
lindquist
parents: 40
diff changeset
713 {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
714 if (DSliceValue* slice = aggrval->isSlice()) {
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
715 Logger::println("foreach over slice");
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
716 niters = slice->len;
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
717 assert(niters);
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
718 val = slice->ptr;
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
719 assert(val);
73
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 54
diff changeset
720 }
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 54
diff changeset
721 else {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
722 Logger::println("foreach over dynamic array");
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
723 val = aggrval->getRVal();
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
724 niters = DtoGEPi(val,0,0,"tmp",p->scopebb());
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
725 niters = p->ir->CreateLoad(niters, "numiterations");
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
726 val = DtoGEPi(val,0,1,"tmp",p->scopebb());
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
727 val = p->ir->CreateLoad(val, "collection");
73
b706170e24a9 [svn r77] Fixed foreach on slice.
lindquist
parents: 54
diff changeset
728 }
45
ff359b65fa62 [svn r49] foreach on dynamic arrays
lindquist
parents: 40
diff changeset
729 }
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
730 else
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
731 {
45
ff359b65fa62 [svn r49] foreach on dynamic arrays
lindquist
parents: 40
diff changeset
732 assert(0 && "aggregate type is not Tarray or Tsarray");
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
733 }
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
734
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
735 if (niters->getType() != keytype)
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
736 {
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
737 size_t sz1 = gTargetData->getTypeSize(niters->getType());
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
738 size_t sz2 = gTargetData->getTypeSize(keytype);
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
739 if (sz1 < sz2)
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
740 niters = gIR->ir->CreateZExt(niters, keytype, "foreachtrunckey");
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
741 else if (sz1 > sz2)
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
742 niters = gIR->ir->CreateTrunc(niters, keytype, "foreachtrunckey");
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
743 else
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
744 niters = gIR->ir->CreateBitCast(niters, keytype, "foreachtrunckey");
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
745 }
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
746
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
747 llvm::Constant* delta = 0;
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
748 if (op == TOKforeach) {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
749 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
750 }
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
751 else {
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
752 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
753 }
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
754
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
755 llvm::BasicBlock* oldend = gIR->scopeend();
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
756 llvm::BasicBlock* condbb = new llvm::BasicBlock("foreachcond", p->topfunc(), oldend);
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
757 llvm::BasicBlock* bodybb = new llvm::BasicBlock("foreachbody", p->topfunc(), oldend);
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
758 llvm::BasicBlock* nextbb = new llvm::BasicBlock("foreachnext", 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
759 llvm::BasicBlock* endbb = new llvm::BasicBlock("foreachend", p->topfunc(), 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
760
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
761 new llvm::BranchInst(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
762
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
763 // condition
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
764 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
765
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
766 llvm::Value* done = 0;
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
767 llvm::Value* load = new llvm::LoadInst(keyvar, "tmp", p->scopebb());
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
768 if (op == TOKforeach) {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
769 done = new llvm::ICmpInst(llvm::ICmpInst::ICMP_ULT, load, niters, "tmp", p->scopebb());
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
770 }
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
771 else if (op == TOKforeach_reverse) {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
772 done = new llvm::ICmpInst(llvm::ICmpInst::ICMP_UGT, load, zerokey, "tmp", p->scopebb());
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
773 load = llvm::BinaryOperator::createSub(load,llvm::ConstantInt::get(keytype, 1, false),"tmp",p->scopebb());
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
774 new llvm::StoreInst(load, keyvar, p->scopebb());
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
775 }
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
776 new llvm::BranchInst(bodybb, endbb, done, p->scopebb());
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
777
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
778 // init body
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
779 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
780
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
781 // get value for this iteration
45
ff359b65fa62 [svn r49] foreach on dynamic arrays
lindquist
parents: 40
diff changeset
782 llvm::Constant* zero = llvm::ConstantInt::get(keytype,0,false);
51
61bc1b4ad3c4 [svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents: 45
diff changeset
783 llvm::Value* loadedKey = p->ir->CreateLoad(keyvar,"tmp");
45
ff359b65fa62 [svn r49] foreach on dynamic arrays
lindquist
parents: 40
diff changeset
784 if (aggrtype->ty == Tsarray)
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
785 value->llvmValue = DtoGEP(val,zero,loadedKey,"tmp");
45
ff359b65fa62 [svn r49] foreach on dynamic arrays
lindquist
parents: 40
diff changeset
786 else if (aggrtype->ty == Tarray)
51
61bc1b4ad3c4 [svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents: 45
diff changeset
787 value->llvmValue = new llvm::GetElementPtrInst(val,loadedKey,"tmp",p->scopebb());
61bc1b4ad3c4 [svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents: 45
diff changeset
788
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
789 if (!value->isRef() && !value->isOut()) {
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
790 DValue* dst = new DVarValue(value->type, valvar, true);
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
791 DValue* src = new DVarValue(value->type, value->llvmValue, true);
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
792 DtoAssign(dst, src);
51
61bc1b4ad3c4 [svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents: 45
diff changeset
793 value->llvmValue = valvar;
61bc1b4ad3c4 [svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents: 45
diff changeset
794 }
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
795
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
796 // emit body
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
797 p->loopbbs.push_back(IRScope(nextbb,endbb));
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
798 body->toIR(p);
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
799 p->loopbbs.pop_back();
32
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
800
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
801 if (!p->scopereturned())
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
802 new llvm::BranchInst(nextbb, p->scopebb());
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
803
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
804 // next
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
805 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
806 if (op == TOKforeach) {
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
807 llvm::Value* load = DtoLoad(keyvar);
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
808 load = p->ir->CreateAdd(load, llvm::ConstantInt::get(keytype, 1, false), "tmp");
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
809 DtoStore(load, keyvar);
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
810 }
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
811 new llvm::BranchInst(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
812
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
813 // 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
814 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
815 }
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
816
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
817 //////////////////////////////////////////////////////////////////////////////
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
818
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
819 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
820 {
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
821 Logger::println("LabelStatement::toIR(): %s", toChars());
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
822 LOG_SCOPE;
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
823
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
824 assert(tf == NULL);
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
825 assert(!isReturnLabel);
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
826
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
827 llvm::BasicBlock* oldend = gIR->scopeend();
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
828 if (llvmBB)
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
829 llvmBB->moveBefore(oldend);
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
830 else
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
831 llvmBB = new llvm::BasicBlock("label", p->topfunc(), oldend);
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
832
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
833 if (!p->scopereturned())
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
834 new llvm::BranchInst(llvmBB, p->scopebb());
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
835
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
836 p->scope() = IRScope(llvmBB,oldend);
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
837 if (statement)
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
838 statement->toIR(p);
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
839 }
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
840
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
841 //////////////////////////////////////////////////////////////////////////////
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
842
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
843 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
844 {
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
845 Logger::println("GotoStatement::toIR(): %s", toChars());
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
846 LOG_SCOPE;
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
847
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
848 assert(tf == NULL);
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
849
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
850 llvm::BasicBlock* oldend = gIR->scopeend();
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
851 llvm::BasicBlock* bb = new llvm::BasicBlock("aftergoto", p->topfunc(), oldend);
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
852
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
853 if (label->statement->llvmBB == NULL)
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
854 label->statement->llvmBB = new llvm::BasicBlock("label", p->topfunc());
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
855 assert(!p->scopereturned());
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
856 new llvm::BranchInst(label->statement->llvmBB, p->scopebb());
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
857 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
858 }
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
859
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
860 //////////////////////////////////////////////////////////////////////////////
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
861
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
862 void WithStatement::toIR(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
863 {
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
864 Logger::println("WithStatement::toIR(): %s", toChars());
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
865 LOG_SCOPE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
866
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
867 assert(exp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
868 assert(body);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
869
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
870 DValue* e = exp->toElem(p);
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
871 wthis->llvmValue = e->getRVal();
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
872 delete e;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
873
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
874 body->toIR(p);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
875 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
876
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
877 //////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
878
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
879 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
880 {
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
881 Logger::println("SynchronizedStatement::toIR(): %s", toChars());
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
882 LOG_SCOPE;
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
883
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
884 Logger::attention("synchronized is currently ignored. only the body will be emitted");
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
885
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
886 body->toIR(p);
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
887 }
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
888
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
889 //////////////////////////////////////////////////////////////////////////////
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
890
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
891 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
892
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
893 #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
894 //STUBST(BreakStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
895 //STUBST(ForStatement);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
896 //STUBST(WithStatement);
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
897 //STUBST(SynchronizedStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
898 //STUBST(ReturnStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
899 //STUBST(ContinueStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
900 STUBST(DefaultStatement);
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
901 //STUBST(CaseStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
902 //STUBST(SwitchStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
903 STUBST(SwitchErrorStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
904 STUBST(Statement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
905 //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
906 //STUBST(ForeachStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
907 //STUBST(DoStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
908 //STUBST(WhileStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
909 //STUBST(ExpStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
910 //STUBST(CompoundStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
911 //STUBST(ScopeStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
912 STUBST(AsmStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
913 //STUBST(TryCatchStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
914 //STUBST(TryFinallyStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
915 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
916 //STUBST(LabelStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
917 //STUBST(ThrowStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
918 STUBST(GotoCaseStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
919 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
920 //STUBST(GotoStatement);
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
921 //STUBST(UnrolledLoopStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
922 //STUBST(OnScopeStatement);