Mercurial > projects > ldc
annotate gen/tollvm.cpp @ 123:7f9a0a58394b trunk
[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.
Removed some potentially very long logging lines.
Added support for inner classes.
author | lindquist |
---|---|
date | Wed, 28 Nov 2007 03:01:51 +0100 |
parents | 9c79b61fb638 |
children | 8096ba7082db |
rev | line source |
---|---|
1 | 1 #include <iostream> |
2 | |
40 | 3 #include "gen/llvm.h" |
1 | 4 |
5 #include "mtype.h" | |
6 #include "dsymbol.h" | |
7 #include "aggregate.h" | |
8 #include "declaration.h" | |
9 #include "init.h" | |
10 | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
11 #include "gen/tollvm.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
12 #include "gen/irstate.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
13 #include "gen/logger.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
14 #include "gen/runtime.h" |
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
15 #include "gen/arrays.h" |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
16 #include "gen/dvalue.h" |
100 | 17 #include "gen/functions.h" |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
18 #include "gen/structs.h" |
100 | 19 #include "gen/classes.h" |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
20 #include "gen/typeinf.h" |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
21 #include "gen/complex.h" |
1 | 22 |
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:
78
diff
changeset
|
23 bool DtoIsPassedByRef(Type* type) |
40 | 24 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
25 Type* typ = DtoDType(type); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
26 TY t = typ->ty; |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
27 return (t == Tstruct || t == Tarray || t == Tdelegate || t == Tsarray || typ->iscomplex()); |
40 | 28 } |
29 | |
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:
78
diff
changeset
|
30 Type* DtoDType(Type* t) |
40 | 31 { |
32 if (t->ty == Ttypedef) { | |
33 Type* bt = t->toBasetype(); | |
34 assert(bt); | |
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:
78
diff
changeset
|
35 return DtoDType(bt); |
40 | 36 } |
37 return t; | |
38 } | |
39 | |
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:
78
diff
changeset
|
40 const llvm::Type* DtoType(Type* t) |
1 | 41 { |
42 assert(t); | |
43 switch (t->ty) | |
44 { | |
45 // integers | |
46 case Tint8: | |
47 case Tuns8: | |
48 case Tchar: | |
49 return (const llvm::Type*)llvm::Type::Int8Ty; | |
50 case Tint16: | |
51 case Tuns16: | |
52 case Twchar: | |
53 return (const llvm::Type*)llvm::Type::Int16Ty; | |
54 case Tint32: | |
55 case Tuns32: | |
56 case Tdchar: | |
57 return (const llvm::Type*)llvm::Type::Int32Ty; | |
58 case Tint64: | |
59 case Tuns64: | |
60 return (const llvm::Type*)llvm::Type::Int64Ty; | |
61 | |
62 case Tbool: | |
63 return (const llvm::Type*)llvm::ConstantInt::getTrue()->getType(); | |
64 | |
65 // floats | |
66 case Tfloat32: | |
62
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
67 case Timaginary32: |
1 | 68 return llvm::Type::FloatTy; |
69 case Tfloat64: | |
62
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
70 case Timaginary64: |
1 | 71 case Tfloat80: |
62
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
72 case Timaginary80: |
1 | 73 return llvm::Type::DoubleTy; |
74 | |
62
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
75 // complex |
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
76 case Tcomplex32: |
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
77 case Tcomplex64: |
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
78 case Tcomplex80: |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
79 return DtoComplexType(t); |
62
b86e00b938a5
[svn r66] Added support for imaginary floating point types
lindquist
parents:
58
diff
changeset
|
80 |
1 | 81 // pointers |
82 case Tpointer: { | |
83 assert(t->next); | |
84 if (t->next->ty == Tvoid) | |
85 return (const llvm::Type*)llvm::PointerType::get(llvm::Type::Int8Ty); | |
86 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:
78
diff
changeset
|
87 return (const llvm::Type*)llvm::PointerType::get(DtoType(t->next)); |
1 | 88 } |
89 | |
90 // arrays | |
91 case Tarray: | |
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:
78
diff
changeset
|
92 return DtoArrayType(t); |
1 | 93 case 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:
78
diff
changeset
|
94 return DtoStaticArrayType(t); |
1 | 95 |
96 // void | |
97 case Tvoid: | |
98 return llvm::Type::VoidTy; | |
99 | |
100 // aggregates | |
101 case Tstruct: { | |
100 | 102 if (!t->llvmType || *t->llvmType == NULL) { |
1 | 103 // recursive or cyclic declaration |
104 if (!gIR->structs.empty()) | |
105 { | |
106 IRStruct* found = 0; | |
107 for (IRState::StructVector::iterator i=gIR->structs.begin(); i!=gIR->structs.end(); ++i) | |
108 { | |
100 | 109 if (t == (*i)->type) |
1 | 110 { |
100 | 111 return (*i)->recty.get(); |
1 | 112 } |
113 } | |
114 } | |
103
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
115 } |
1 | 116 |
103
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
117 TypeStruct* ts = (TypeStruct*)t; |
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
118 assert(ts->sym); |
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
119 DtoResolveDsymbol(ts->sym); |
100 | 120 return t->llvmType->get(); |
1 | 121 } |
122 | |
123 case Tclass: { | |
100 | 124 if (!t->llvmType || *t->llvmType == NULL) { |
6 | 125 // recursive or cyclic declaration |
126 if (!gIR->structs.empty()) | |
127 { | |
128 IRStruct* found = 0; | |
129 for (IRState::StructVector::iterator i=gIR->structs.begin(); i!=gIR->structs.end(); ++i) | |
130 { | |
100 | 131 if (t == (*i)->type) |
6 | 132 { |
100 | 133 return llvm::PointerType::get((*i)->recty.get()); |
6 | 134 } |
135 } | |
136 } | |
103
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
137 } |
6 | 138 |
103
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
139 TypeClass* tc = (TypeClass*)t; |
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
140 assert(tc->sym); |
855adfdb8d38
[svn r107] Getting .classinfo on a class instance now works (classinfo is stored in vtable)
lindquist
parents:
102
diff
changeset
|
141 DtoResolveDsymbol(tc->sym); |
100 | 142 return llvm::PointerType::get(t->llvmType->get()); |
1 | 143 } |
144 | |
145 // functions | |
146 case Tfunction: | |
147 { | |
100 | 148 if (!t->llvmType || *t->llvmType == NULL) { |
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:
78
diff
changeset
|
149 return DtoFunctionType(t,NULL); |
1 | 150 } |
151 else { | |
100 | 152 return t->llvmType->get(); |
1 | 153 } |
154 } | |
6 | 155 |
1 | 156 // delegates |
157 case Tdelegate: | |
158 { | |
100 | 159 if (!t->llvmType || *t->llvmType == NULL) { |
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:
78
diff
changeset
|
160 return DtoDelegateType(t); |
1 | 161 } |
162 else { | |
100 | 163 return t->llvmType->get(); |
1 | 164 } |
165 } | |
166 | |
167 // typedefs | |
52 | 168 // enum |
1 | 169 case Ttypedef: |
52 | 170 case Tenum: |
1 | 171 { |
172 Type* bt = t->toBasetype(); | |
173 assert(bt); | |
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:
78
diff
changeset
|
174 return DtoType(bt); |
1 | 175 } |
176 | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
177 // associative arrays |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
178 case Taarray: |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
179 { |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
180 TypeAArray* taa = (TypeAArray*)t; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
181 std::vector<const llvm::Type*> types; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
182 types.push_back(DtoType(taa->key)); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
183 types.push_back(DtoType(taa->next)); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
184 return llvm::PointerType::get(llvm::StructType::get(types)); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
185 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
186 |
1 | 187 default: |
188 printf("trying to convert unknown type with value %d\n", t->ty); | |
189 assert(0); | |
190 } | |
191 return 0; | |
192 } | |
193 | |
194 ////////////////////////////////////////////////////////////////////////////////////////// | |
195 | |
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:
78
diff
changeset
|
196 const llvm::StructType* DtoDelegateType(Type* t) |
1 | 197 { |
198 const llvm::Type* i8ptr = llvm::PointerType::get(llvm::Type::Int8Ty); | |
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:
78
diff
changeset
|
199 const llvm::Type* func = DtoFunctionType(t->next, i8ptr); |
1 | 200 const llvm::Type* funcptr = llvm::PointerType::get(func); |
201 | |
202 std::vector<const llvm::Type*> types; | |
203 types.push_back(i8ptr); | |
204 types.push_back(funcptr); | |
205 return llvm::StructType::get(types); | |
206 } | |
207 | |
208 ////////////////////////////////////////////////////////////////////////////////////////// | |
209 | |
210 static llvm::Function* LLVM_DeclareMemIntrinsic(const char* name, int bits, bool set=false) | |
211 { | |
212 assert(bits == 32 || bits == 64); | |
213 const llvm::Type* int8ty = (const llvm::Type*)llvm::Type::Int8Ty; | |
214 const llvm::Type* int32ty = (const llvm::Type*)llvm::Type::Int32Ty; | |
215 const llvm::Type* int64ty = (const llvm::Type*)llvm::Type::Int64Ty; | |
216 const llvm::Type* int8ptrty = (const llvm::Type*)llvm::PointerType::get(llvm::Type::Int8Ty); | |
217 const llvm::Type* voidty = (const llvm::Type*)llvm::Type::VoidTy; | |
218 | |
219 assert(gIR); | |
220 assert(gIR->module); | |
221 | |
222 // parameter types | |
223 std::vector<const llvm::Type*> pvec; | |
224 pvec.push_back(int8ptrty); | |
225 pvec.push_back(set?int8ty:int8ptrty); | |
226 pvec.push_back(bits==32?int32ty:int64ty); | |
227 pvec.push_back(int32ty); | |
228 llvm::FunctionType* functype = llvm::FunctionType::get(voidty, pvec, false); | |
229 return new llvm::Function(functype, llvm::GlobalValue::ExternalLinkage, name, gIR->module); | |
230 } | |
231 | |
232 ////////////////////////////////////////////////////////////////////////////////////////// | |
233 | |
234 // llvm.memset.i32 | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
235 llvm::Function* LLVM_DeclareMemSet32() |
1 | 236 { |
237 static llvm::Function* _func = 0; | |
238 if (_func == 0) { | |
239 _func = LLVM_DeclareMemIntrinsic("llvm.memset.i32", 32, true); | |
240 } | |
241 return _func; | |
242 } | |
243 | |
244 ////////////////////////////////////////////////////////////////////////////////////////// | |
245 | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
246 llvm::Function* LLVM_DeclareMemSet64() |
1 | 247 { |
248 static llvm::Function* _func = 0; | |
249 if (_func == 0) { | |
250 _func = LLVM_DeclareMemIntrinsic("llvm.memset.i64", 64, true); | |
251 } | |
252 return _func; | |
253 } | |
254 | |
255 ////////////////////////////////////////////////////////////////////////////////////////// | |
256 | |
257 // llvm.memcpy.i32 | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
258 llvm::Function* LLVM_DeclareMemCpy32() |
1 | 259 { |
260 static llvm::Function* _func = 0; | |
261 if (_func == 0) { | |
262 _func = LLVM_DeclareMemIntrinsic("llvm.memcpy.i32", 32); | |
263 } | |
264 return _func; | |
265 } | |
266 | |
267 ////////////////////////////////////////////////////////////////////////////////////////// | |
268 | |
269 // llvm.memcpy.i64 | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
270 llvm::Function* LLVM_DeclareMemCpy64() |
1 | 271 { |
272 static llvm::Function* _func = 0; | |
273 if (_func == 0) { | |
274 _func = LLVM_DeclareMemIntrinsic("llvm.memcpy.i64", 64); | |
275 } | |
276 return _func; | |
277 } | |
278 | |
279 ////////////////////////////////////////////////////////////////////////////////////////// | |
280 | |
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:
78
diff
changeset
|
281 llvm::Value* DtoNullDelegate(llvm::Value* v) |
1 | 282 { |
283 assert(gIR); | |
284 d_uns64 n = (global.params.is64bit) ? 16 : 8; | |
285 | |
286 llvm::Type* i8p_ty = llvm::PointerType::get(llvm::Type::Int8Ty); | |
287 | |
288 llvm::Value* arr = new llvm::BitCastInst(v,i8p_ty,"tmp",gIR->scopebb()); | |
289 | |
290 llvm::Function* fn = LLVM_DeclareMemSet32(); | |
291 std::vector<llvm::Value*> llargs; | |
292 llargs.resize(4); | |
293 llargs[0] = arr; | |
294 llargs[1] = llvm::ConstantInt::get(llvm::Type::Int8Ty, 0, false); | |
295 llargs[2] = llvm::ConstantInt::get(llvm::Type::Int32Ty, n, false); | |
296 llargs[3] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); | |
297 | |
298 llvm::Value* ret = new llvm::CallInst(fn, llargs.begin(), llargs.end(), "", gIR->scopebb()); | |
299 | |
300 return ret; | |
301 } | |
302 | |
303 ////////////////////////////////////////////////////////////////////////////////////////// | |
304 | |
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:
78
diff
changeset
|
305 llvm::Value* DtoDelegateCopy(llvm::Value* dst, llvm::Value* src) |
1 | 306 { |
307 assert(dst->getType() == src->getType()); | |
308 assert(gIR); | |
309 | |
310 d_uns64 n = (global.params.is64bit) ? 16 : 8; | |
311 | |
312 llvm::Type* arrty = llvm::PointerType::get(llvm::Type::Int8Ty); | |
313 | |
314 llvm::Value* dstarr = new llvm::BitCastInst(dst,arrty,"tmp",gIR->scopebb()); | |
315 llvm::Value* srcarr = new llvm::BitCastInst(src,arrty,"tmp",gIR->scopebb()); | |
316 | |
317 llvm::Function* fn = LLVM_DeclareMemCpy32(); | |
318 std::vector<llvm::Value*> llargs; | |
319 llargs.resize(4); | |
320 llargs[0] = dstarr; | |
321 llargs[1] = srcarr; | |
322 llargs[2] = llvm::ConstantInt::get(llvm::Type::Int32Ty, n, false); | |
323 llargs[3] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); | |
324 | |
325 return new llvm::CallInst(fn, llargs.begin(), llargs.end(), "", gIR->scopebb()); | |
326 } | |
327 | |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
328 ////////////////////////////////////////////////////////////////////////////////////////// |
1 | 329 |
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:
78
diff
changeset
|
330 llvm::Value* DtoCompareDelegate(TOK op, llvm::Value* lhs, llvm::Value* rhs) |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
331 { |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
332 llvm::ICmpInst::Predicate pred = (op == TOKequal) ? llvm::ICmpInst::ICMP_EQ : llvm::ICmpInst::ICMP_NE; |
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:
78
diff
changeset
|
333 llvm::Value* l = gIR->ir->CreateLoad(DtoGEPi(lhs,0,0,"tmp"),"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:
78
diff
changeset
|
334 llvm::Value* r = gIR->ir->CreateLoad(DtoGEPi(rhs,0,0,"tmp"),"tmp"); |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
335 llvm::Value* b1 = gIR->ir->CreateICmp(pred,l,r,"tmp"); |
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:
78
diff
changeset
|
336 l = gIR->ir->CreateLoad(DtoGEPi(lhs,0,1,"tmp"),"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:
78
diff
changeset
|
337 r = gIR->ir->CreateLoad(DtoGEPi(rhs,0,1,"tmp"),"tmp"); |
53
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
338 llvm::Value* b2 = gIR->ir->CreateICmp(pred,l,r,"tmp"); |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
339 llvm::Value* b = gIR->ir->CreateAnd(b1,b2,"tmp"); |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
340 if (op == TOKnotequal) |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
341 return gIR->ir->CreateNot(b,"tmp"); |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
342 return b; |
06ccc817acd4
[svn r57] Added most basic TypeInfo (rebuild lphobos).
lindquist
parents:
52
diff
changeset
|
343 } |
1 | 344 |
345 ////////////////////////////////////////////////////////////////////////////////////////// | |
346 | |
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:
78
diff
changeset
|
347 llvm::GlobalValue::LinkageTypes DtoLinkage(PROT prot, uint stc) |
1 | 348 { |
349 switch(prot) | |
350 { | |
351 case PROTprivate: | |
352 return llvm::GlobalValue::InternalLinkage; | |
353 | |
354 case PROTpublic: | |
355 case PROTpackage: | |
356 case PROTprotected: | |
357 case PROTexport: | |
358 return llvm::GlobalValue::ExternalLinkage; | |
359 | |
360 case PROTundefined: | |
361 case PROTnone: | |
362 assert(0 && "Unsupported linkage type"); | |
363 } | |
364 return llvm::GlobalValue::ExternalLinkage; | |
365 | |
366 /* ExternalLinkage = 0, LinkOnceLinkage, WeakLinkage, AppendingLinkage, | |
367 InternalLinkage, DLLImportLinkage, DLLExportLinkage, ExternalWeakLinkage, | |
368 GhostLinkage */ | |
369 } | |
370 | |
371 ////////////////////////////////////////////////////////////////////////////////////////// | |
372 | |
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:
78
diff
changeset
|
373 unsigned DtoCallingConv(LINK l) |
1 | 374 { |
375 if (l == LINKc) | |
376 return llvm::CallingConv::C; | |
377 else if (l == LINKd || l == LINKdefault) | |
378 return llvm::CallingConv::Fast; | |
379 else if (l == LINKwindows) | |
380 return llvm::CallingConv::X86_StdCall; | |
381 else | |
382 assert(0 && "Unsupported calling convention"); | |
383 } | |
384 | |
385 ////////////////////////////////////////////////////////////////////////////////////////// | |
386 | |
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:
78
diff
changeset
|
387 llvm::Value* DtoPointedType(llvm::Value* ptr, llvm::Value* val) |
1 | 388 { |
389 const llvm::Type* ptrTy = ptr->getType()->getContainedType(0); | |
390 const llvm::Type* valTy = val->getType(); | |
391 // ptr points to val's type | |
392 if (ptrTy == valTy) | |
393 { | |
394 return val; | |
395 } | |
396 // ptr is integer pointer | |
397 else if (ptrTy->isInteger()) | |
398 { | |
399 // val is integer | |
400 assert(valTy->isInteger()); | |
401 const llvm::IntegerType* pt = llvm::cast<const llvm::IntegerType>(ptrTy); | |
402 const llvm::IntegerType* vt = llvm::cast<const llvm::IntegerType>(valTy); | |
403 if (pt->getBitWidth() < vt->getBitWidth()) { | |
404 return new llvm::TruncInst(val, pt, "tmp", gIR->scopebb()); | |
405 } | |
406 else | |
407 assert(0); | |
408 } | |
409 // something else unsupported | |
410 else | |
411 { | |
412 Logger::cout() << *ptrTy << '|' << *valTy << '\n'; | |
413 assert(0); | |
414 } | |
415 return 0; | |
416 } | |
417 | |
418 ////////////////////////////////////////////////////////////////////////////////////////// | |
419 | |
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:
78
diff
changeset
|
420 llvm::Value* DtoBoolean(llvm::Value* val) |
1 | 421 { |
422 const llvm::Type* t = val->getType(); | |
423 if (t->isInteger()) | |
424 { | |
425 if (t == llvm::Type::Int1Ty) | |
426 return val; | |
427 else { | |
428 llvm::Value* zero = llvm::ConstantInt::get(t, 0, false); | |
429 return new llvm::ICmpInst(llvm::ICmpInst::ICMP_NE, val, zero, "tmp", gIR->scopebb()); | |
430 } | |
431 } | |
96 | 432 else if (isaPointer(t)) { |
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:
78
diff
changeset
|
433 const llvm::Type* st = DtoSize_t(); |
1 | 434 llvm::Value* ptrasint = new llvm::PtrToIntInst(val,st,"tmp",gIR->scopebb()); |
435 llvm::Value* zero = llvm::ConstantInt::get(st, 0, false); | |
436 return new llvm::ICmpInst(llvm::ICmpInst::ICMP_NE, ptrasint, zero, "tmp", gIR->scopebb()); | |
437 } | |
438 else | |
439 { | |
440 Logger::cout() << *t << '\n'; | |
441 } | |
442 assert(0); | |
443 return 0; | |
444 } | |
445 | |
446 ////////////////////////////////////////////////////////////////////////////////////////// | |
447 | |
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:
78
diff
changeset
|
448 const llvm::Type* DtoSize_t() |
1 | 449 { |
450 if (global.params.is64bit) | |
451 return llvm::Type::Int64Ty; | |
452 else | |
453 return llvm::Type::Int32Ty; | |
454 } | |
455 | |
456 ////////////////////////////////////////////////////////////////////////////////////////// | |
457 | |
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:
78
diff
changeset
|
458 llvm::Constant* DtoConstInitializer(Type* type, Initializer* init) |
1 | 459 { |
21
8d45266bbabe
[svn r25] * Fixed a lot of problems with string literals
lindquist
parents:
18
diff
changeset
|
460 llvm::Constant* _init = 0; // may return zero |
1 | 461 if (!init) |
462 { | |
40 | 463 Logger::println("const default initializer for %s", type->toChars()); |
464 _init = type->defaultInit()->toConstElem(gIR); | |
1 | 465 } |
466 else if (ExpInitializer* ex = init->isExpInitializer()) | |
467 { | |
40 | 468 Logger::println("const expression initializer"); |
469 _init = ex->exp->toConstElem(gIR); | |
1 | 470 } |
471 else if (StructInitializer* si = init->isStructInitializer()) | |
472 { | |
40 | 473 Logger::println("const struct initializer"); |
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:
78
diff
changeset
|
474 _init = DtoConstStructInitializer(si); |
1 | 475 } |
476 else if (ArrayInitializer* ai = init->isArrayInitializer()) | |
477 { | |
40 | 478 Logger::println("const array initializer"); |
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:
78
diff
changeset
|
479 _init = DtoConstArrayInitializer(ai); |
1 | 480 } |
481 else if (init->isVoidInitializer()) | |
482 { | |
40 | 483 Logger::println("const void initializer"); |
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:
78
diff
changeset
|
484 const llvm::Type* ty = DtoType(type); |
1 | 485 _init = llvm::Constant::getNullValue(ty); |
486 } | |
487 else { | |
40 | 488 Logger::println("unsupported const initializer: %s", init->toChars()); |
489 } | |
490 return _init; | |
491 } | |
492 | |
493 ////////////////////////////////////////////////////////////////////////////////////////// | |
494 | |
100 | 495 llvm::Constant* DtoConstFieldInitializer(Type* t, Initializer* init) |
496 { | |
497 Logger::println("DtoConstFieldInitializer"); | |
498 LOG_SCOPE; | |
499 | |
500 const llvm::Type* _type = DtoType(t); | |
501 | |
502 llvm::Constant* _init = DtoConstInitializer(t, init); | |
503 assert(_init); | |
504 if (_type != _init->getType()) | |
505 { | |
506 Logger::cout() << "field init is: " << *_init << " type should be " << *_type << '\n'; | |
507 if (t->ty == Tsarray) | |
508 { | |
509 const llvm::ArrayType* arrty = isaArray(_type); | |
510 uint64_t n = arrty->getNumElements(); | |
511 std::vector<llvm::Constant*> vals(n,_init); | |
512 _init = llvm::ConstantArray::get(arrty, vals); | |
513 } | |
514 else if (t->ty == Tarray) | |
515 { | |
516 assert(isaStruct(_type)); | |
517 _init = llvm::ConstantAggregateZero::get(_type); | |
518 } | |
519 else if (t->ty == Tstruct) | |
520 { | |
521 const llvm::StructType* structty = isaStruct(_type); | |
522 TypeStruct* ts = (TypeStruct*)t; | |
523 assert(ts); | |
524 assert(ts->sym); | |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
116
diff
changeset
|
525 assert(ts->sym->llvmConstInit); |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
116
diff
changeset
|
526 _init = ts->sym->llvmConstInit; |
100 | 527 } |
528 else if (t->ty == Tclass) | |
529 { | |
530 _init = llvm::Constant::getNullValue(_type); | |
531 } | |
532 else { | |
533 Logger::println("failed for type %s", t->toChars()); | |
534 assert(0); | |
535 } | |
536 } | |
537 | |
538 return _init; | |
539 } | |
540 | |
541 ////////////////////////////////////////////////////////////////////////////////////////// | |
542 | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
543 DValue* DtoInitializer(Initializer* init) |
40 | 544 { |
545 if (ExpInitializer* ex = init->isExpInitializer()) | |
546 { | |
547 Logger::println("expression initializer"); | |
92 | 548 assert(ex->exp); |
85
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
549 return ex->exp->toElem(gIR); |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
550 } |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
551 else if (init->isVoidInitializer()) |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
552 { |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
553 // do nothing |
40 | 554 } |
555 else { | |
1 | 556 Logger::println("unsupported initializer: %s", init->toChars()); |
85
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
557 assert(0); |
1 | 558 } |
85
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
559 return 0; |
1 | 560 } |
6 | 561 |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
562 ////////////////////////////////////////////////////////////////////////////////////////// |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
563 |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
78
diff
changeset
|
564 llvm::Value* DtoGEP(llvm::Value* ptr, llvm::Value* i0, llvm::Value* i1, const std::string& var, llvm::BasicBlock* bb) |
6 | 565 { |
566 std::vector<llvm::Value*> v(2); | |
567 v[0] = i0; | |
568 v[1] = i1; | |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
569 //Logger::cout() << "DtoGEP: " << *ptr << '\n'; |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
570 return new llvm::GetElementPtrInst(ptr, v.begin(), v.end(), var, bb?bb:gIR->scopebb()); |
6 | 571 } |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
572 |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
573 ////////////////////////////////////////////////////////////////////////////////////////// |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
574 |
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:
78
diff
changeset
|
575 llvm::Value* DtoGEP(llvm::Value* ptr, const std::vector<unsigned>& src, const std::string& var, llvm::BasicBlock* bb) |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
576 { |
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
577 size_t n = src.size(); |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
578 std::vector<llvm::Value*> dst(n, NULL); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
579 //std::ostream& ostr = Logger::cout(); |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
580 //ostr << "indices for '" << *ptr << "':"; |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
581 for (size_t i=0; i<n; ++i) |
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
582 { |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
583 //ostr << ' ' << i; |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
584 dst[i] = llvm::ConstantInt::get(llvm::Type::Int32Ty, src[i], false); |
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
585 } |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
586 //ostr << '\n';*/ |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
587 return new llvm::GetElementPtrInst(ptr, dst.begin(), dst.end(), var, bb?bb:gIR->scopebb()); |
8
5e69b77a5c51
[svn r12] fixed accessing aggregate fields of aggregates
lindquist
parents:
6
diff
changeset
|
588 } |
9 | 589 |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
590 ////////////////////////////////////////////////////////////////////////////////////////// |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
591 |
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:
78
diff
changeset
|
592 llvm::Value* DtoGEPi(llvm::Value* ptr, unsigned i, const std::string& var, llvm::BasicBlock* bb) |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
593 { |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
594 return new llvm::GetElementPtrInst(ptr, llvm::ConstantInt::get(llvm::Type::Int32Ty, i, false), var, bb?bb:gIR->scopebb()); |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
595 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
596 |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
597 ////////////////////////////////////////////////////////////////////////////////////////// |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
598 |
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:
78
diff
changeset
|
599 llvm::Value* DtoGEPi(llvm::Value* ptr, unsigned i0, unsigned i1, const std::string& var, llvm::BasicBlock* bb) |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
600 { |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
601 std::vector<llvm::Value*> v(2); |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
602 v[0] = llvm::ConstantInt::get(llvm::Type::Int32Ty, i0, false); |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
603 v[1] = llvm::ConstantInt::get(llvm::Type::Int32Ty, i1, false); |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
604 return new llvm::GetElementPtrInst(ptr, v.begin(), v.end(), var, bb?bb:gIR->scopebb()); |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
605 } |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
606 |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
607 ////////////////////////////////////////////////////////////////////////////////////////// |
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
608 |
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:
78
diff
changeset
|
609 llvm::Value* DtoRealloc(llvm::Value* ptr, const llvm::Type* ty) |
34 | 610 { |
611 /*size_t sz = gTargetData->getTypeSize(ty); | |
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:
78
diff
changeset
|
612 llvm::ConstantInt* n = llvm::ConstantInt::get(DtoSize_t(), sz, false); |
34 | 613 if (ptr == 0) { |
614 llvm::PointerType* i8pty = llvm::PointerType::get(llvm::Type::Int8Ty); | |
615 ptr = llvm::ConstantPointerNull::get(i8pty); | |
616 } | |
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:
78
diff
changeset
|
617 return DtoRealloc(ptr, n);*/ |
34 | 618 return NULL; |
619 } | |
620 | |
621 ////////////////////////////////////////////////////////////////////////////////////////// | |
622 | |
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:
78
diff
changeset
|
623 llvm::Value* DtoRealloc(llvm::Value* ptr, llvm::Value* n) |
34 | 624 { |
625 assert(ptr); | |
626 assert(n); | |
627 | |
628 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_realloc"); | |
629 assert(fn); | |
630 | |
631 llvm::Value* newptr = ptr; | |
632 | |
633 llvm::PointerType* i8pty = llvm::PointerType::get(llvm::Type::Int8Ty); | |
634 if (ptr->getType() != i8pty) { | |
635 newptr = new llvm::BitCastInst(ptr,i8pty,"tmp",gIR->scopebb()); | |
636 } | |
637 | |
638 std::vector<llvm::Value*> args; | |
639 args.push_back(newptr); | |
640 args.push_back(n); | |
641 llvm::Value* ret = new llvm::CallInst(fn, args.begin(), args.end(), "tmprealloc", gIR->scopebb()); | |
642 | |
643 return ret->getType() == ptr->getType() ? ret : new llvm::BitCastInst(ret,ptr->getType(),"tmp",gIR->scopebb()); | |
644 } | |
645 | |
646 ////////////////////////////////////////////////////////////////////////////////////////// | |
647 | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
648 void DtoAssert(llvm::Value* cond, Loc* loc, DValue* msg) |
34 | 649 { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
650 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_assert"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
651 const llvm::FunctionType* fnt = fn->getFunctionType(); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
652 |
34 | 653 std::vector<llvm::Value*> llargs; |
654 llargs.resize(3); | |
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:
78
diff
changeset
|
655 llargs[0] = cond ? DtoBoolean(cond) : llvm::ConstantInt::getFalse(); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
656 llargs[1] = DtoConstUint(loc->linnum); |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
657 if (msg) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
658 llargs[2] = msg->getRVal(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
659 else { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
660 llvm::Constant* c = DtoConstSlice(DtoConstSize_t(0), DtoConstNullPtr(llvm::Type::Int8Ty)); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
661 static llvm::AllocaInst* alloc = 0; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
662 if (!alloc || alloc->getParent()->getParent() != gIR->func()->func) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
663 alloc = new llvm::AllocaInst(c->getType(), "assertnullparam", gIR->topallocapoint()); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
664 DtoSetArrayToNull(alloc); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
665 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
666 llargs[2] = alloc; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
667 } |
34 | 668 |
669 assert(fn); | |
670 llvm::CallInst* call = new llvm::CallInst(fn, llargs.begin(), llargs.end(), "", gIR->scopebb()); | |
671 call->setCallingConv(llvm::CallingConv::C); | |
672 } | |
673 | |
40 | 674 ////////////////////////////////////////////////////////////////////////////////////////// |
34 | 675 |
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:
78
diff
changeset
|
676 llvm::Value* DtoArgument(const llvm::Type* paramtype, Argument* fnarg, Expression* argexp) |
40 | 677 { |
678 llvm::Value* retval = 0; | |
679 | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
680 bool haslvals = !gIR->exps.empty(); |
40 | 681 if (haslvals) |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
682 gIR->exps.push_back(IRExp(NULL,NULL,NULL)); |
40 | 683 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
684 DValue* arg = argexp->toElem(gIR); |
40 | 685 |
686 if (haslvals) | |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
687 gIR->exps.pop_back(); |
40 | 688 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
689 if (arg->inPlace()) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
690 retval = arg->getRVal(); |
40 | 691 return retval; |
692 } | |
693 | |
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:
78
diff
changeset
|
694 Type* realtype = DtoDType(argexp->type); |
40 | 695 TY argty = realtype->ty; |
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:
78
diff
changeset
|
696 if (DtoIsPassedByRef(realtype)) { |
40 | 697 if (!fnarg || !fnarg->llvmCopy) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
698 if (DSliceValue* sv = arg->isSlice()) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
699 retval = new llvm::AllocaInst(DtoType(realtype), "tmpparam", gIR->topallocapoint()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
700 DtoSetArray(retval, DtoArrayLen(sv), DtoArrayPtr(sv)); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
701 } |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
702 else if (DComplexValue* cv = arg->isComplex()) { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
703 retval = new llvm::AllocaInst(DtoType(realtype), "tmpparam", gIR->topallocapoint()); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
704 DtoComplexSet(retval, cv->re, cv->im); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
705 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
706 else { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
707 retval = arg->getRVal(); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
708 } |
40 | 709 } |
710 else { | |
711 llvm::Value* allocaInst = 0; | |
712 llvm::BasicBlock* entryblock = &gIR->topfunc()->front(); | |
96 | 713 |
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:
78
diff
changeset
|
714 const llvm::Type* realtypell = DtoType(realtype); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
715 const llvm::PointerType* pty = llvm::PointerType::get(realtypell); |
40 | 716 if (argty == Tstruct) { |
717 allocaInst = new llvm::AllocaInst(pty->getElementType(), "tmpparam", gIR->topallocapoint()); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
718 DValue* dst = new DVarValue(realtype, allocaInst, true); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
719 DtoAssign(dst,arg); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
720 delete dst; |
40 | 721 } |
722 else if (argty == Tdelegate) { | |
723 allocaInst = new llvm::AllocaInst(pty->getElementType(), "tmpparam", gIR->topallocapoint()); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
724 DValue* dst = new DVarValue(realtype, allocaInst, true); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
725 DtoAssign(dst,arg); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
726 delete dst; |
40 | 727 } |
728 else if (argty == Tarray) { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
729 if (arg->isSlice()) { |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
730 allocaInst = new llvm::AllocaInst(realtypell, "tmpparam", gIR->topallocapoint()); |
83
339422268de1
[svn r87] Fixed some memory bloat when passing string literals as char[] params (double temporary before)
lindquist
parents:
82
diff
changeset
|
731 } |
40 | 732 else { |
733 allocaInst = new llvm::AllocaInst(pty->getElementType(), "tmpparam", gIR->topallocapoint()); | |
734 } | |
735 } | |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
736 else if (realtype->iscomplex()) { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
737 if (arg->isComplex()) { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
738 allocaInst = new llvm::AllocaInst(realtypell, "tmpparam", gIR->topallocapoint()); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
739 } |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
740 else { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
741 allocaInst = new llvm::AllocaInst(pty->getElementType(), "tmpparam", gIR->topallocapoint()); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
742 } |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
743 } |
40 | 744 else |
745 assert(0); | |
746 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
747 DValue* dst = new DVarValue(realtype, allocaInst, true); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
748 DtoAssign(dst,arg); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
749 delete dst; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
750 |
40 | 751 retval = allocaInst; |
752 } | |
753 } | |
754 else if (!fnarg || fnarg->llvmCopy) { | |
755 Logger::println("regular arg"); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
756 if (DSliceValue* sl = arg->isSlice()) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
757 if (sl->ptr) Logger::cout() << "ptr = " << *sl->ptr << '\n'; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
758 if (sl->len) Logger::cout() << "len = " << *sl->len << '\n'; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
759 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
760 } |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
761 else if (DComplexValue* cl = arg->isComplex()) { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
762 assert(0 && "complex in the wrong place"); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
763 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
764 else { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
765 retval = arg->getRVal(); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
766 } |
40 | 767 } |
768 else { | |
769 Logger::println("as ptr arg"); | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
770 retval = arg->getLVal(); |
57
a9d29e9f1fed
[svn r61] Added support for D-style variadic functions :)
lindquist
parents:
55
diff
changeset
|
771 if (paramtype && retval->getType() != paramtype) |
40 | 772 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
773 assert(0); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
774 /*assert(retval->getType() == paramtype->getContainedType(0)); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
775 new llvm::StoreInst(retval, arg->getLVal(), gIR->scopebb()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
776 retval = arg->getLVal();*/ |
40 | 777 } |
778 } | |
779 | |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
780 if (fnarg && paramtype && retval->getType() != paramtype) { |
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
781 // this is unfortunately needed with the way SymOffExp is overused |
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
782 // and static arrays can end up being a pointer to their element type |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
783 if (arg->isField()) { |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
784 retval = gIR->ir->CreateBitCast(retval, paramtype, "tmp"); |
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
785 } |
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
786 else { |
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
787 Logger::cout() << "got '" << *retval->getType() << "' expected '" << *paramtype << "'\n"; |
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
788 assert(0 && "parameter type that was actually passed is invalid"); |
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
789 } |
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
790 } |
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
77
diff
changeset
|
791 |
40 | 792 delete arg; |
793 | |
794 return retval; | |
795 } | |
34 | 796 |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
797 ////////////////////////////////////////////////////////////////////////////////////////// |
34 | 798 |
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:
78
diff
changeset
|
799 llvm::Value* DtoNestedVariable(VarDeclaration* vd) |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
800 { |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
801 FuncDeclaration* fd = vd->toParent()->isFuncDeclaration(); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
802 assert(fd != NULL); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
803 |
100 | 804 IRFunction* fcur = gIR->func(); |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
805 FuncDeclaration* f = fcur->decl; |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
806 |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
807 // on this stack |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
808 if (fd == f) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
809 llvm::Value* vdv = vd->llvmValue; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
810 if (!vdv) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
811 { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
812 Logger::println(":o null vd->llvmValue for: %s", vd->toChars()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
813 vdv = fd->llvmNested; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
814 assert(vdv); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
815 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
816 assert(vd->llvmNestedIndex != ~0); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
817 llvm::Value* v = DtoGEPi(vdv,0,unsigned(vd->llvmNestedIndex),"tmp"); |
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:
78
diff
changeset
|
818 if (vd->isParameter() && (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type))) { |
73 | 819 Logger::cout() << "1267 loading: " << *v << '\n'; |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
62
diff
changeset
|
820 v = gIR->ir->CreateLoad(v,"tmp"); |
73 | 821 } |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
62
diff
changeset
|
822 return v; |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
823 } |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
824 |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
825 // on a caller stack |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
826 llvm::Value* ptr = f->llvmThisVar; |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
827 assert(ptr); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
828 |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
829 f = f->toParent()->isFuncDeclaration(); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
830 assert(f); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
831 assert(f->llvmNested); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
832 const llvm::Type* nesttype = f->llvmNested->getType(); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
833 assert(nesttype); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
834 |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
835 ptr = gIR->ir->CreateBitCast(ptr, nesttype, "tmp"); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
836 |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
837 Logger::cout() << "nested var reference:" << '\n' << *ptr << *nesttype << '\n'; |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
838 |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
839 while (f) { |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
840 if (fd == f) { |
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:
78
diff
changeset
|
841 llvm::Value* v = DtoGEPi(ptr,0,vd->llvmNestedIndex,"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:
78
diff
changeset
|
842 if (vd->isParameter() && (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type))) { |
73 | 843 Logger::cout() << "1291 loading: " << *v << '\n'; |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
62
diff
changeset
|
844 v = gIR->ir->CreateLoad(v,"tmp"); |
73 | 845 } |
67
f918f3e2e99e
[svn r71] Fixed accessing parent function arguments from inside nested delegates.
lindquist
parents:
62
diff
changeset
|
846 return v; |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
847 } |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
848 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:
78
diff
changeset
|
849 ptr = DtoGEPi(ptr,0,0,"tmp"); |
50
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
850 ptr = gIR->ir->CreateLoad(ptr,"tmp"); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
851 } |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
852 f = f->toParent()->isFuncDeclaration(); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
853 } |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
854 |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
855 assert(0 && "nested var not found"); |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
856 return NULL; |
6fcc08a4d406
[svn r54] Added support for nested delegates referencing parent's stack variables.
lindquist
parents:
49
diff
changeset
|
857 } |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
858 |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
859 ////////////////////////////////////////////////////////////////////////////////////////// |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
860 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
861 void DtoAssign(DValue* lhs, DValue* rhs) |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
862 { |
92 | 863 Logger::cout() << "DtoAssign(...);\n"; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
864 Type* t = DtoDType(lhs->getType()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
865 Type* t2 = DtoDType(rhs->getType()); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
866 |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
867 if (t->ty == Tstruct) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
868 if (t2 != t) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
869 // TODO: fix this, use 'rhs' for something |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
870 DtoStructZeroInit(lhs->getLVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
871 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
872 else if (!rhs->inPlace()) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
873 DtoStructCopy(lhs->getLVal(),rhs->getRVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
874 } |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
875 } |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
876 else if (t->ty == Tarray) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
877 // lhs is slice |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
878 if (DSliceValue* s = lhs->isSlice()) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
879 if (DSliceValue* s2 = rhs->isSlice()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
880 DtoArrayCopySlices(s, s2); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
881 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
882 else if (t->next == t2) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
883 if (s->len) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
884 DtoArrayInit(s->ptr, s->len, rhs->getRVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
885 else |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
886 DtoArrayInit(s->ptr, rhs->getRVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
887 } |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
888 else { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
889 DtoArrayCopyToSlice(s, rhs); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
890 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
891 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
892 // rhs is slice |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
893 else if (DSliceValue* s = rhs->isSlice()) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
894 DtoSetArray(lhs->getLVal(),s->len,s->ptr); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
895 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
896 // null |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
897 else if (rhs->isNull()) { |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
898 DtoSetArrayToNull(lhs->getLVal()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
899 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
900 // reference assignment |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
901 else { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
902 DtoArrayAssign(lhs->getLVal(), rhs->getRVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
903 } |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
904 } |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
905 else if (t->ty == Tsarray) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
906 DtoStaticArrayCopy(lhs->getLVal(), rhs->getRVal()); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
907 } |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
908 else if (t->ty == Tdelegate) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
909 if (rhs->isNull()) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
910 DtoNullDelegate(lhs->getLVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
911 else if (!rhs->inPlace()) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
912 DtoDelegateCopy(lhs->getLVal(), rhs->getRVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
913 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
914 else if (t->ty == Tclass) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
915 assert(t2->ty == Tclass); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
916 // assignment to this in constructor special case |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
917 if (lhs->isThis()) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
918 llvm::Value* tmp = rhs->getRVal(); |
100 | 919 FuncDeclaration* fdecl = gIR->func()->decl; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
920 // respecify the this param |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
921 if (!llvm::isa<llvm::AllocaInst>(fdecl->llvmThisVar)) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
922 fdecl->llvmThisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
923 DtoStore(tmp, fdecl->llvmThisVar); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
924 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
925 // regular class ref -> class ref assignment |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
926 else { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
927 DtoStore(rhs->getRVal(), lhs->getLVal()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
928 } |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
929 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
930 else if (t->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
931 assert(!lhs->isComplex()); |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
932 |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
933 llvm::Value* dst; |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
934 if (DLRValue* lr = lhs->isLRValue()) { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
935 dst = lr->getLVal(); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
936 rhs = DtoCastComplex(rhs, lr->getLType()); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
937 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
938 else { |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
939 dst = lhs->getRVal(); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
940 } |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
941 |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
942 if (DComplexValue* cx = rhs->isComplex()) |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
943 DtoComplexSet(dst, cx->re, cx->im); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
944 else |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
945 DtoComplexAssign(dst, rhs->getRVal()); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
946 } |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
947 else { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
948 llvm::Value* l; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
949 if (DLRValue* lr = lhs->isLRValue()) { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
950 l = lr->getLVal(); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
951 rhs = DtoCast(rhs, lr->getLType()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
952 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
953 else { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
954 l = lhs->getLVal(); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
955 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
956 llvm::Value* r = rhs->getRVal(); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
957 Logger::cout() << "assign\nlhs: " << *l << "rhs: " << *r << '\n'; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
958 const llvm::Type* lit = l->getType()->getContainedType(0); |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
959 if (r->getType() != lit) { // :( |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
960 r = DtoBitCast(r, lit); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
961 Logger::cout() << "really assign\nlhs: " << *l << "rhs: " << *r << '\n'; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
962 } |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
963 gIR->ir->CreateStore(r, l); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
964 } |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
50
diff
changeset
|
965 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
966 |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
967 ////////////////////////////////////////////////////////////////////////////////////////// |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
968 DValue* DtoCastInt(DValue* val, Type* _to) |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
969 { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
970 const llvm::Type* tolltype = DtoType(_to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
971 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
972 Type* to = DtoDType(_to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
973 Type* from = DtoDType(val->getType()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
974 assert(from->isintegral()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
975 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
976 size_t fromsz = from->size(); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
977 size_t tosz = to->size(); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
978 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
979 llvm::Value* rval; |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
980 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
981 if (to->isintegral()) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
982 if (fromsz < tosz) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
983 Logger::cout() << "cast to: " << *tolltype << '\n'; |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
984 if (from->isunsigned() || from->ty == Tbool) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
985 rval = new llvm::ZExtInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
986 } else { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
987 rval = new llvm::SExtInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
988 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
989 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
990 else if (fromsz > tosz) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
991 rval = new llvm::TruncInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
992 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
993 else { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
994 rval = new llvm::BitCastInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
995 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
996 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
997 else if (to->isfloating()) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
998 if (from->isunsigned()) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
999 rval = new llvm::UIToFPInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1000 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1001 else { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1002 rval = new llvm::SIToFPInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1003 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1004 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1005 else if (to->ty == Tpointer) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1006 rval = gIR->ir->CreateIntToPtr(val->getRVal(), tolltype, "tmp"); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1007 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1008 else { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1009 assert(0 && "bad int cast"); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1010 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1011 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1012 return new DImValue(_to, rval); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1013 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1014 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1015 DValue* DtoCastPtr(DValue* val, Type* to) |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1016 { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1017 const llvm::Type* tolltype = DtoType(to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1018 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1019 Type* totype = DtoDType(to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1020 Type* fromtype = DtoDType(val->getType()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1021 assert(fromtype->ty == Tpointer); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1022 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1023 llvm::Value* rval; |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1024 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1025 if (totype->ty == Tpointer || totype->ty == Tclass) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1026 llvm::Value* src = val->getRVal(); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1027 Logger::cout() << "src: " << *src << "to type: " << *tolltype << '\n'; |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1028 rval = new llvm::BitCastInst(src, tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1029 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1030 else if (totype->isintegral()) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1031 rval = new llvm::PtrToIntInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1032 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1033 else { |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1034 Logger::println("invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars()); |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1035 assert(0); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1036 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1037 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1038 return new DImValue(to, rval); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1039 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1040 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1041 DValue* DtoCastFloat(DValue* val, Type* to) |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1042 { |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1043 if (val->getType() == to) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1044 return val; |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1045 |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1046 const llvm::Type* tolltype = DtoType(to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1047 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1048 Type* totype = DtoDType(to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1049 Type* fromtype = DtoDType(val->getType()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1050 assert(fromtype->isfloating()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1051 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1052 size_t fromsz = fromtype->size(); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1053 size_t tosz = totype->size(); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1054 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1055 llvm::Value* rval; |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1056 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1057 if (totype->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1058 assert(0); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1059 //return new DImValue(to, DtoComplex(to, val)); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1060 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1061 else if (totype->isfloating()) { |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1062 if ((fromtype->ty == Tfloat80 || fromtype->ty == Tfloat64) && (totype->ty == Tfloat80 || totype->ty == Tfloat64)) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1063 rval = val->getRVal(); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1064 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1065 else if (fromsz < tosz) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1066 rval = new llvm::FPExtInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1067 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1068 else if (fromsz > tosz) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1069 rval = new llvm::FPTruncInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1070 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1071 else { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1072 assert(0 && "bad float cast"); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1073 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1074 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1075 else if (totype->isintegral()) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1076 if (totype->isunsigned()) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1077 rval = new llvm::FPToUIInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1078 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1079 else { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1080 rval = new llvm::FPToSIInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1081 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1082 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1083 else { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1084 assert(0 && "bad float cast"); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1085 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1086 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1087 return new DImValue(to, rval); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1088 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1089 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1090 DValue* DtoCastComplex(DValue* val, Type* _to) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1091 { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1092 Type* to = DtoDType(_to); |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1093 Type* vty = val->getType(); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1094 if (to->iscomplex()) { |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1095 if (vty->size() == to->size()) |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1096 return val; |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1097 |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1098 llvm::Value *re, *im; |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1099 DtoGetComplexParts(val, re, im); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1100 const llvm::Type* toty = DtoComplexBaseType(to); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1101 |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1102 if (to->size() < vty->size()) { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1103 re = gIR->ir->CreateFPTrunc(re, toty, "tmp"); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1104 im = gIR->ir->CreateFPTrunc(im, toty, "tmp"); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1105 } |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1106 else if (to->size() > vty->size()) { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1107 re = gIR->ir->CreateFPExt(re, toty, "tmp"); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1108 im = gIR->ir->CreateFPExt(im, toty, "tmp"); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1109 } |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1110 else { |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1111 return val; |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1112 } |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1113 |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1114 if (val->isComplex()) |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1115 return new DComplexValue(_to, re, im); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1116 |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1117 // unfortunately at this point, the cast value can show up as the lvalue for += and similar expressions. |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1118 // so we need to give it storage, or fix the system that handles this stuff (DLRValue) |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1119 llvm::Value* mem = new llvm::AllocaInst(DtoType(_to), "castcomplextmp", gIR->topallocapoint()); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1120 DtoComplexSet(mem, re, im); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1121 return new DLRValue(val->getType(), val->getRVal(), _to, mem); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1122 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1123 else if (to->isimaginary()) { |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1124 if (val->isComplex()) |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1125 return new DImValue(to, val->isComplex()->im); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1126 llvm::Value* v = val->getRVal(); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1127 DImValue* im = new DImValue(to, DtoLoad(DtoGEPi(v,0,1,"tmp"))); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1128 return DtoCastFloat(im, to); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1129 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1130 else if (to->isfloating()) { |
107
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1131 if (val->isComplex()) |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1132 return new DImValue(to, val->isComplex()->re); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1133 llvm::Value* v = val->getRVal(); |
3efbcc81ba45
[svn r111] Fixed most problems with complex number support and added typeinfo for them.
lindquist
parents:
106
diff
changeset
|
1134 DImValue* re = new DImValue(to, DtoLoad(DtoGEPi(v,0,0,"tmp"))); |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1135 return DtoCastFloat(re, to); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1136 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1137 else |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1138 assert(0); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1139 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1140 |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1141 DValue* DtoCast(DValue* val, Type* to) |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1142 { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1143 Type* fromtype = DtoDType(val->getType()); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
107
diff
changeset
|
1144 Logger::println("Casting from '%s' to '%s'", fromtype->toChars(), to->toChars()); |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1145 if (fromtype->isintegral()) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1146 return DtoCastInt(val, to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1147 } |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1148 else if (fromtype->iscomplex()) { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1149 return DtoCastComplex(val, to); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1150 } |
97
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1151 else if (fromtype->isfloating()) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1152 return DtoCastFloat(val, to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1153 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1154 else if (fromtype->ty == Tclass) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1155 return DtoCastClass(val, to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1156 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1157 else if (fromtype->ty == Tarray || fromtype->ty == Tsarray) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1158 return DtoCastArray(val, to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1159 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1160 else if (fromtype->ty == Tpointer) { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1161 return DtoCastPtr(val, to); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1162 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1163 else { |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1164 assert(0); |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1165 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1166 } |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1167 |
c4e161556a21
[svn r101] Split up CastExp into several smaller utility functions.
lindquist
parents:
96
diff
changeset
|
1168 ////////////////////////////////////////////////////////////////////////////////////////// |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1169 |
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:
78
diff
changeset
|
1170 llvm::ConstantInt* DtoConstSize_t(size_t i) |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1171 { |
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:
78
diff
changeset
|
1172 return llvm::ConstantInt::get(DtoSize_t(), i, false); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1173 } |
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:
78
diff
changeset
|
1174 llvm::ConstantInt* DtoConstUint(unsigned i) |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1175 { |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1176 return llvm::ConstantInt::get(llvm::Type::Int32Ty, i, false); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1177 } |
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:
78
diff
changeset
|
1178 llvm::ConstantInt* DtoConstInt(int i) |
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:
78
diff
changeset
|
1179 { |
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:
78
diff
changeset
|
1180 return llvm::ConstantInt::get(llvm::Type::Int32Ty, i, true); |
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:
78
diff
changeset
|
1181 } |
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:
78
diff
changeset
|
1182 llvm::Constant* DtoConstBool(bool b) |
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:
78
diff
changeset
|
1183 { |
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:
78
diff
changeset
|
1184 return llvm::ConstantInt::get(llvm::Type::Int1Ty, b, false); |
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:
78
diff
changeset
|
1185 } |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1186 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1187 llvm::ConstantFP* DtoConstFP(Type* t, long double value) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1188 { |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1189 TY ty = DtoDType(t)->ty; |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1190 if (ty == Tfloat32 || ty == Timaginary32) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1191 return llvm::ConstantFP::get(llvm::Type::FloatTy, float(value)); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1192 else if (ty == Tfloat64 || ty == Timaginary64 || ty == Tfloat80 || ty == Timaginary80) |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1193 return llvm::ConstantFP::get(llvm::Type::DoubleTy, double(value)); |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1194 } |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1195 |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1196 |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1197 ////////////////////////////////////////////////////////////////////////////////////////// |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1198 |
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:
78
diff
changeset
|
1199 llvm::Constant* DtoConstString(const char* str) |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1200 { |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1201 std::string s(str); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1202 llvm::Constant* init = llvm::ConstantArray::get(s, true); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1203 llvm::GlobalVariable* gvar = new llvm::GlobalVariable( |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1204 init->getType(), true,llvm::GlobalValue::InternalLinkage, init, "stringliteral", gIR->module); |
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:
78
diff
changeset
|
1205 llvm::Constant* idxs[2] = { DtoConstUint(0), DtoConstUint(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:
78
diff
changeset
|
1206 return DtoConstSlice( |
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:
78
diff
changeset
|
1207 DtoConstSize_t(s.length()), |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1208 llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2) |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1209 ); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
53
diff
changeset
|
1210 } |
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
|
1211 llvm::Constant* DtoConstStringPtr(const char* str, const char* section) |
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
|
1212 { |
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
|
1213 std::string s(str); |
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
|
1214 llvm::Constant* init = llvm::ConstantArray::get(s, true); |
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
|
1215 llvm::GlobalVariable* gvar = new llvm::GlobalVariable( |
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
|
1216 init->getType(), true,llvm::GlobalValue::InternalLinkage, init, "stringliteral", gIR->module); |
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
|
1217 if (section) gvar->setSection(section); |
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
|
1218 llvm::Constant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; |
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
|
1219 return llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); |
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
|
1220 } |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1221 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1222 ////////////////////////////////////////////////////////////////////////////////////////// |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1223 |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1224 llvm::Constant* DtoConstNullPtr(const llvm::Type* t) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1225 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1226 return llvm::ConstantPointerNull::get( |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1227 llvm::PointerType::get(t) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1228 ); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1229 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1230 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1231 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1232 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1233 void DtoMemSetZero(llvm::Value* dst, llvm::Value* nbytes) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1234 { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1235 llvm::Type* arrty = llvm::PointerType::get(llvm::Type::Int8Ty); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1236 llvm::Value *dstarr; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1237 if (dst->getType() == arrty) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1238 { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1239 dstarr = dst; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1240 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1241 else |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1242 { |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1243 dstarr = new llvm::BitCastInst(dst,arrty,"tmp",gIR->scopebb()); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1244 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1245 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1246 llvm::Function* fn = (global.params.is64bit) ? LLVM_DeclareMemSet64() : LLVM_DeclareMemSet32(); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1247 std::vector<llvm::Value*> llargs; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1248 llargs.resize(4); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1249 llargs[0] = dstarr; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1250 llargs[1] = llvm::ConstantInt::get(llvm::Type::Int8Ty, 0, false); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1251 llargs[2] = nbytes; |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1252 llargs[3] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1253 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1254 new llvm::CallInst(fn, llargs.begin(), llargs.end(), "", gIR->scopebb()); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1255 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1256 |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1257 ////////////////////////////////////////////////////////////////////////////////////////// |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
1258 |
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:
78
diff
changeset
|
1259 void DtoMemCpy(llvm::Value* dst, llvm::Value* src, llvm::Value* nbytes) |
58
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1260 { |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1261 assert(dst->getType() == src->getType()); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1262 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1263 llvm::Type* arrty = llvm::PointerType::get(llvm::Type::Int8Ty); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1264 llvm::Value *dstarr, *srcarr; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1265 if (dst->getType() == arrty) |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1266 { |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1267 dstarr = dst; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1268 srcarr = src; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1269 } |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1270 else |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1271 { |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1272 dstarr = new llvm::BitCastInst(dst,arrty,"tmp",gIR->scopebb()); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1273 srcarr = new llvm::BitCastInst(src,arrty,"tmp",gIR->scopebb()); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1274 } |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1275 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1276 llvm::Function* fn = (global.params.is64bit) ? LLVM_DeclareMemCpy64() : LLVM_DeclareMemCpy32(); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1277 std::vector<llvm::Value*> llargs; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1278 llargs.resize(4); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1279 llargs[0] = dstarr; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1280 llargs[1] = srcarr; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1281 llargs[2] = nbytes; |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1282 llargs[3] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1283 |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1284 new llvm::CallInst(fn, llargs.begin(), llargs.end(), "", gIR->scopebb()); |
2c3cd3596187
[svn r62] Added support for TypeInfo _Array, _Function, _Pointer, _Delegate, _Enum
lindquist
parents:
57
diff
changeset
|
1285 } |
77
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
73
diff
changeset
|
1286 |
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
73
diff
changeset
|
1287 ////////////////////////////////////////////////////////////////////////////////////////// |
714057ff2dbb
[svn r81] Fixed: Union support was very buggy. Should be fairly solid now.
lindquist
parents:
73
diff
changeset
|
1288 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1289 llvm::Value* DtoLoad(llvm::Value* src) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1290 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1291 return gIR->ir->CreateLoad(src,"tmp"); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1292 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1293 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1294 void DtoStore(llvm::Value* src, llvm::Value* dst) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1295 { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1296 gIR->ir->CreateStore(src,dst); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1297 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1298 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1299 bool DtoCanLoad(llvm::Value* ptr) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1300 { |
96 | 1301 if (isaPointer(ptr->getType())) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1302 return ptr->getType()->getContainedType(0)->isFirstClassType(); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1303 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1304 return false; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1305 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1306 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1307 ////////////////////////////////////////////////////////////////////////////////////////// |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1308 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1309 llvm::Value* DtoBitCast(llvm::Value* v, const llvm::Type* t) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1310 { |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1311 if (v->getType() == t) |
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
97
diff
changeset
|
1312 return v; |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1313 return gIR->ir->CreateBitCast(v, t, "tmp"); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1314 } |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1315 |
104
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1316 ////////////////////////////////////////////////////////////////////////////////////////// |
4d1e9eb001e0
[svn r108] Now basic suppport for complex types. =,+,-,*,/ are supported.
lindquist
parents:
103
diff
changeset
|
1317 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1318 const llvm::PointerType* isaPointer(llvm::Value* v) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1319 { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1320 return llvm::dyn_cast<llvm::PointerType>(v->getType()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1321 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1322 |
96 | 1323 const llvm::PointerType* isaPointer(const llvm::Type* t) |
1324 { | |
1325 return llvm::dyn_cast<llvm::PointerType>(t); | |
1326 } | |
1327 | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1328 const llvm::ArrayType* isaArray(llvm::Value* v) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1329 { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1330 return llvm::dyn_cast<llvm::ArrayType>(v->getType()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1331 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1332 |
96 | 1333 const llvm::ArrayType* isaArray(const llvm::Type* t) |
1334 { | |
1335 return llvm::dyn_cast<llvm::ArrayType>(t); | |
1336 } | |
1337 | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1338 const llvm::StructType* isaStruct(llvm::Value* v) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1339 { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1340 return llvm::dyn_cast<llvm::StructType>(v->getType()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1341 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1342 |
96 | 1343 const llvm::StructType* isaStruct(const llvm::Type* t) |
1344 { | |
1345 return llvm::dyn_cast<llvm::StructType>(t); | |
1346 } | |
1347 | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1348 llvm::Constant* isaConstant(llvm::Value* v) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1349 { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1350 return llvm::dyn_cast<llvm::Constant>(v); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1351 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1352 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1353 llvm::ConstantInt* isaConstantInt(llvm::Value* v) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1354 { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1355 return llvm::dyn_cast<llvm::ConstantInt>(v); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1356 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1357 |
96 | 1358 llvm::Argument* isaArgument(llvm::Value* v) |
1359 { | |
1360 return llvm::dyn_cast<llvm::Argument>(v); | |
1361 } | |
1362 | |
106 | 1363 llvm::GlobalVariable* isaGlobalVar(llvm::Value* v) |
1364 { | |
1365 return llvm::dyn_cast<llvm::GlobalVariable>(v); | |
1366 } | |
1367 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1368 ////////////////////////////////////////////////////////////////////////////////////////// |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1369 |
85
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
1370 bool DtoIsTemplateInstance(Dsymbol* s) |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
1371 { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
85
diff
changeset
|
1372 if (!s) return false; |
85
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
1373 if (s->isTemplateInstance() && !s->isTemplateMixin()) |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
1374 return true; |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
1375 else if (s->parent) |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
1376 return DtoIsTemplateInstance(s->parent); |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
1377 return false; |
f869c636a113
[svn r89] Fixed a bunch of problems with template instance across multiple modules.
lindquist
parents:
83
diff
changeset
|
1378 } |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1379 |
99
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1380 ////////////////////////////////////////////////////////////////////////////////////////// |
a676a7743642
[svn r103] Array comparisons are now fully implemented, that is - to the extent that TypeInfo is.
lindquist
parents:
98
diff
changeset
|
1381 |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1382 void DtoLazyStaticInit(bool istempl, llvm::Value* gvar, Initializer* init, Type* t) |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1383 { |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1384 // create a flag to make sure initialization only happens once |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1385 llvm::GlobalValue::LinkageTypes gflaglink = istempl ? llvm::GlobalValue::WeakLinkage : llvm::GlobalValue::InternalLinkage; |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1386 std::string gflagname(gvar->getName()); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1387 gflagname.append("__initflag"); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1388 llvm::GlobalVariable* gflag = new llvm::GlobalVariable(llvm::Type::Int1Ty,false,gflaglink,DtoConstBool(false),gflagname,gIR->module); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1389 |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1390 // check flag and do init if not already done |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1391 llvm::BasicBlock* oldend = gIR->scopeend(); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1392 llvm::BasicBlock* initbb = new llvm::BasicBlock("ifnotinit",gIR->topfunc(),oldend); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1393 llvm::BasicBlock* endinitbb = new llvm::BasicBlock("ifnotinitend",gIR->topfunc(),oldend); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1394 llvm::Value* cond = gIR->ir->CreateICmpEQ(gIR->ir->CreateLoad(gflag,"tmp"),DtoConstBool(false)); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1395 gIR->ir->CreateCondBr(cond, initbb, endinitbb); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1396 gIR->scope() = IRScope(initbb,endinitbb); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
93
diff
changeset
|
1397 DValue* ie = DtoInitializer(init); |
88
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1398 if (!ie->inPlace()) { |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1399 DValue* dst = new DVarValue(t, gvar, true); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1400 DtoAssign(dst, ie); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1401 } |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1402 gIR->ir->CreateStore(DtoConstBool(true), gflag); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1403 gIR->ir->CreateBr(endinitbb); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1404 gIR->scope() = IRScope(endinitbb,oldend); |
058d3925950e
[svn r92] Fixed support for statically initialized unions. lots of bugfixes as cleanups too.
lindquist
parents:
86
diff
changeset
|
1405 } |
100 | 1406 |
1407 ////////////////////////////////////////////////////////////////////////////////////////// | |
1408 | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1409 void DtoResolveDsymbol(Dsymbol* dsym) |
100 | 1410 { |
1411 if (StructDeclaration* sd = dsym->isStructDeclaration()) { | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1412 DtoResolveStruct(sd); |
100 | 1413 } |
1414 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) { | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1415 DtoResolveClass(cd); |
100 | 1416 } |
1417 else if (FuncDeclaration* fd = dsym->isFuncDeclaration()) { | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1418 DtoResolveFunction(fd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1419 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1420 else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1421 DtoResolveTypeInfo(fd); |
100 | 1422 } |
1423 else { | |
1424 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars()); | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1425 assert(0 && "unsupported dsymbol for DtoResolveDsymbol"); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1426 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1427 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1428 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1429 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1430 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1431 void DtoDeclareDsymbol(Dsymbol* dsym) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1432 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1433 if (StructDeclaration* sd = dsym->isStructDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1434 DtoDeclareStruct(sd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1435 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1436 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1437 DtoDeclareClass(cd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1438 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1439 else if (FuncDeclaration* fd = dsym->isFuncDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1440 DtoDeclareFunction(fd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1441 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1442 else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1443 DtoDeclareTypeInfo(fd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1444 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1445 else { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1446 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars()); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1447 assert(0 && "unsupported dsymbol for DtoDeclareDsymbol"); |
100 | 1448 } |
1449 } | |
1450 | |
1451 ////////////////////////////////////////////////////////////////////////////////////////// | |
1452 | |
1453 void DtoConstInitDsymbol(Dsymbol* dsym) | |
1454 { | |
1455 if (StructDeclaration* sd = dsym->isStructDeclaration()) { | |
1456 DtoConstInitStruct(sd); | |
1457 } | |
1458 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) { | |
1459 DtoConstInitClass(cd); | |
1460 } | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1461 else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1462 DtoConstInitTypeInfo(fd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1463 } |
100 | 1464 else if (VarDeclaration* vd = dsym->isVarDeclaration()) { |
1465 DtoConstInitGlobal(vd); | |
1466 } | |
1467 else { | |
1468 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars()); | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1469 assert(0 && "unsupported dsymbol for DtoConstInitDsymbol"); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1470 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1471 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1472 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1473 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1474 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1475 void DtoDefineDsymbol(Dsymbol* dsym) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1476 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1477 if (StructDeclaration* sd = dsym->isStructDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1478 DtoDefineStruct(sd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1479 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1480 else if (ClassDeclaration* cd = dsym->isClassDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1481 DtoDefineClass(cd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1482 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1483 else if (FuncDeclaration* fd = dsym->isFuncDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1484 DtoDefineFunc(fd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1485 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1486 else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1487 DtoDefineTypeInfo(fd); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1488 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1489 else { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1490 error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars()); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1491 assert(0 && "unsupported dsymbol for DtoDefineDsymbol"); |
100 | 1492 } |
1493 } | |
1494 | |
1495 ////////////////////////////////////////////////////////////////////////////////////////// | |
1496 | |
1497 void DtoConstInitGlobal(VarDeclaration* vd) | |
1498 { | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1499 if (vd->llvmInitialized) return; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1500 vd->llvmInitialized = gIR->dmodule; |
100 | 1501 |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1502 Logger::println("* DtoConstInitGlobal(%s)", vd->toChars()); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1503 LOG_SCOPE; |
100 | 1504 |
1505 bool emitRTstaticInit = false; | |
1506 | |
1507 llvm::Constant* _init = 0; | |
1508 if (vd->parent && vd->parent->isFuncDeclaration() && vd->init && vd->init->isExpInitializer()) { | |
1509 _init = DtoConstInitializer(vd->type, NULL); | |
1510 emitRTstaticInit = true; | |
1511 } | |
1512 else { | |
1513 _init = DtoConstInitializer(vd->type, vd->init); | |
1514 } | |
1515 | |
1516 const llvm::Type* _type = DtoType(vd->type); | |
1517 Type* t = DtoDType(vd->type); | |
1518 | |
1519 //Logger::cout() << "initializer: " << *_init << '\n'; | |
1520 if (_type != _init->getType()) { | |
1521 Logger::cout() << "got type '" << *_init->getType() << "' expected '" << *_type << "'\n"; | |
1522 // zero initalizer | |
1523 if (_init->isNullValue()) | |
1524 _init = llvm::Constant::getNullValue(_type); | |
1525 // pointer to global constant (struct.init) | |
1526 else if (llvm::isa<llvm::GlobalVariable>(_init)) | |
1527 { | |
1528 assert(_init->getType()->getContainedType(0) == _type); | |
1529 llvm::GlobalVariable* gv = llvm::cast<llvm::GlobalVariable>(_init); | |
1530 assert(t->ty == Tstruct); | |
1531 TypeStruct* ts = (TypeStruct*)t; | |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
116
diff
changeset
|
1532 assert(ts->sym->llvmConstInit); |
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
116
diff
changeset
|
1533 _init = ts->sym->llvmConstInit; |
100 | 1534 } |
1535 // array single value init | |
1536 else if (isaArray(_type)) | |
1537 { | |
1538 _init = DtoConstStaticArray(_type, _init); | |
1539 } | |
1540 else { | |
1541 Logger::cout() << "Unexpected initializer type: " << *_type << '\n'; | |
1542 //assert(0); | |
1543 } | |
1544 } | |
1545 | |
1546 bool istempl = false; | |
1547 if ((vd->storage_class & STCcomdat) || (vd->parent && DtoIsTemplateInstance(vd->parent))) { | |
1548 istempl = true; | |
1549 } | |
1550 | |
1551 if (_init && _init->getType() != _type) | |
1552 _type = _init->getType(); | |
1553 llvm::cast<llvm::OpaqueType>(vd->llvmIRGlobal->type.get())->refineAbstractTypeTo(_type); | |
1554 _type = vd->llvmIRGlobal->type.get(); | |
1555 assert(!_type->isAbstract()); | |
1556 | |
1557 llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(vd->llvmValue); | |
1558 if (!(vd->storage_class & STCextern) && (vd->getModule() == gIR->dmodule || istempl)) | |
1559 { | |
1560 gvar->setInitializer(_init); | |
1561 } | |
1562 | |
1563 if (emitRTstaticInit) | |
1564 DtoLazyStaticInit(istempl, gvar, vd->init, t); | |
1565 } | |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1566 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1567 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1568 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1569 void DtoEmptyResolveList() |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1570 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1571 //Logger::println("DtoEmptyResolveList()"); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1572 Dsymbol* dsym; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1573 while (!gIR->resolveList.empty()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1574 dsym = gIR->resolveList.front(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1575 gIR->resolveList.pop_front(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1576 DtoResolveDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1577 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1578 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1579 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1580 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1581 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1582 void DtoEmptyDeclareList() |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1583 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1584 //Logger::println("DtoEmptyDeclareList()"); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1585 Dsymbol* dsym; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1586 while (!gIR->declareList.empty()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1587 dsym = gIR->declareList.front(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1588 gIR->declareList.pop_front(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1589 DtoDeclareDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1590 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1591 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1592 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1593 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1594 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1595 void DtoEmptyConstInitList() |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1596 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1597 //Logger::println("DtoEmptyConstInitList()"); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1598 Dsymbol* dsym; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1599 while (!gIR->constInitList.empty()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1600 dsym = gIR->constInitList.front(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1601 gIR->constInitList.pop_front(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1602 DtoConstInitDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1603 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1604 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1605 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1606 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1607 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1608 void DtoEmptyDefineList() |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1609 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1610 //Logger::println("DtoEmptyDefineList()"); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1611 Dsymbol* dsym; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1612 while (!gIR->defineList.empty()) { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1613 dsym = gIR->defineList.front(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1614 gIR->defineList.pop_front(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1615 DtoDefineDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1616 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1617 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1618 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1619 ////////////////////////////////////////////////////////////////////////////////////////// |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1620 void DtoEmptyAllLists() |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1621 { |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1622 for(;;) |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1623 { |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1624 Dsymbol* dsym; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1625 if (!gIR->resolveList.empty()) { |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1626 dsym = gIR->resolveList.front(); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1627 gIR->resolveList.pop_front(); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1628 DtoResolveDsymbol(dsym); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1629 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1630 else if (!gIR->declareList.empty()) { |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1631 dsym = gIR->declareList.front(); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1632 gIR->declareList.pop_front(); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1633 DtoDeclareDsymbol(dsym); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1634 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1635 else if (!gIR->constInitList.empty()) { |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1636 dsym = gIR->constInitList.front(); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1637 gIR->constInitList.pop_front(); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1638 DtoConstInitDsymbol(dsym); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1639 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1640 else if (!gIR->defineList.empty()) { |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1641 dsym = gIR->defineList.front(); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1642 gIR->defineList.pop_front(); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1643 DtoDefineDsymbol(dsym); |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1644 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1645 else { |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1646 break; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1647 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1648 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1649 } |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1650 |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
114
diff
changeset
|
1651 ////////////////////////////////////////////////////////////////////////////////////////// |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1652 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1653 void DtoForceDeclareDsymbol(Dsymbol* dsym) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1654 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1655 if (dsym->llvmDeclared) return; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1656 Logger::println("DtoForceDeclareDsymbol(%s)", dsym->toChars()); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1657 LOG_SCOPE; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1658 DtoResolveDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1659 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1660 DtoEmptyResolveList(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1661 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1662 DtoDeclareDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1663 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1664 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1665 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1666 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1667 void DtoForceConstInitDsymbol(Dsymbol* dsym) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1668 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1669 if (dsym->llvmInitialized) return; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1670 Logger::println("DtoForceConstInitDsymbol(%s)", dsym->toChars()); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1671 LOG_SCOPE; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1672 DtoResolveDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1673 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1674 DtoEmptyResolveList(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1675 DtoEmptyDeclareList(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1676 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1677 DtoConstInitDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1678 } |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1679 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1680 ////////////////////////////////////////////////////////////////////////////////////////// |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1681 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1682 void DtoForceDefineDsymbol(Dsymbol* dsym) |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1683 { |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1684 if (dsym->llvmDefined) return; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1685 Logger::println("DtoForceDefineDsymbol(%s)", dsym->toChars()); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1686 LOG_SCOPE; |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1687 DtoResolveDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1688 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1689 DtoEmptyResolveList(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1690 DtoEmptyDeclareList(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1691 DtoEmptyConstInitList(); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1692 |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1693 DtoDefineDsymbol(dsym); |
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
1694 } |