Mercurial > projects > ldc
comparison gen/tocall.cpp @ 486:a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Reimplemented support for nested functions/class using a new approach.
Added error on taking address of intrinsic.
Fixed problems with the ->syntaxCopy of TypeFunction delegate exp.
Removed DtoDType and replaced all uses with ->toBasetype() instead.
Removed unused inplace stuff.
Fixed a bunch of issues in the runtime unittests, not complete yet.
Added mini tests.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 10 Aug 2008 08:37:38 +0200 |
parents | 672eb4893b55 |
children | 993b217af574 |
comparison
equal
deleted
inserted
replaced
485:50f6e2337a6b | 486:a34078905d01 |
---|---|
69 return fn->getRVal(); | 69 return fn->getRVal(); |
70 } | 70 } |
71 else if (type->ty == Tdelegate) | 71 else if (type->ty == Tdelegate) |
72 { | 72 { |
73 LLValue* dg = fn->getRVal(); | 73 LLValue* dg = fn->getRVal(); |
74 Logger::cout() << "delegate: " << *dg << '\n'; | |
74 LLValue* funcptr = DtoGEPi(dg, 0, 1); | 75 LLValue* funcptr = DtoGEPi(dg, 0, 1); |
75 return DtoLoad(funcptr); | 76 return DtoLoad(funcptr); |
76 } | 77 } |
77 else | 78 else |
78 { | 79 { |
198 | 199 |
199 // get function type info | 200 // get function type info |
200 TypeFunction* tf = DtoTypeFunction(fnval); | 201 TypeFunction* tf = DtoTypeFunction(fnval); |
201 | 202 |
202 // misc | 203 // misc |
203 bool retinptr = tf->llvmRetInPtr; | 204 bool retinptr = tf->retInPtr; |
204 bool usesthis = tf->llvmUsesThis; | 205 bool thiscall = tf->usesThis; |
205 bool delegatecall = (calleeType->toBasetype()->ty == Tdelegate); | 206 bool delegatecall = (calleeType->toBasetype()->ty == Tdelegate); |
206 bool nestedcall = (dfnval && dfnval->func && dfnval->func->isNested()); | 207 bool nestedcall = tf->usesNest; |
207 bool dvarargs = (tf->linkage == LINKd && tf->varargs == 1); | 208 bool dvarargs = (tf->linkage == LINKd && tf->varargs == 1); |
208 | 209 |
209 unsigned callconv = DtoCallingConv(tf->linkage); | 210 unsigned callconv = DtoCallingConv(tf->linkage); |
210 | 211 |
211 // get callee llvm value | 212 // get callee llvm value |
219 | 220 |
220 // parameter attributes | 221 // parameter attributes |
221 llvm::PAListPtr palist; | 222 llvm::PAListPtr palist; |
222 | 223 |
223 // return attrs | 224 // return attrs |
224 if (tf->llvmRetAttrs) | 225 if (tf->retAttrs) |
225 palist = palist.addAttr(0, tf->llvmRetAttrs); | 226 palist = palist.addAttr(0, tf->retAttrs); |
226 | 227 |
227 // handle implicit arguments | 228 // handle implicit arguments |
228 std::vector<LLValue*> args; | 229 std::vector<LLValue*> args; |
229 | 230 |
230 // return in hidden ptr is first | 231 // return in hidden ptr is first |
235 args.push_back(retvar); | 236 args.push_back(retvar); |
236 palist = palist.addAttr(1, llvm::ParamAttr::StructRet); | 237 palist = palist.addAttr(1, llvm::ParamAttr::StructRet); |
237 } | 238 } |
238 | 239 |
239 // then comes a context argument... | 240 // then comes a context argument... |
240 if(usesthis || delegatecall || nestedcall) | 241 if(thiscall || delegatecall || nestedcall) |
241 { | 242 { |
242 // ... which can be a 'this' argument | 243 // ... which can be a 'this' argument |
243 if (dfnval && dfnval->vthis) | 244 if (thiscall) |
244 { | 245 { |
246 assert(dfnval && dfnval->vthis); | |
245 LLValue* thisarg = DtoBitCast(dfnval->vthis, argiter->get()); | 247 LLValue* thisarg = DtoBitCast(dfnval->vthis, argiter->get()); |
246 ++argiter; | 248 ++argiter; |
247 args.push_back(thisarg); | 249 args.push_back(thisarg); |
248 } | 250 } |
249 // ... or a delegate context arg | 251 // ... or a delegate context arg |
255 args.push_back(ctxarg); | 257 args.push_back(ctxarg); |
256 } | 258 } |
257 // ... or a nested function context arg | 259 // ... or a nested function context arg |
258 else if (nestedcall) | 260 else if (nestedcall) |
259 { | 261 { |
260 LLValue* contextptr = DtoNestedContext(dfnval->func->toParent2()->isFuncDeclaration()); | 262 LLValue* contextptr = DtoNestedContext(loc, dfnval->func); |
261 if (!contextptr) | 263 contextptr = DtoBitCast(contextptr, getVoidPtrType()); |
262 contextptr = getNullPtr(getVoidPtrType()); | |
263 else | |
264 contextptr = DtoBitCast(contextptr, getVoidPtrType()); | |
265 ++argiter; | 264 ++argiter; |
266 args.push_back(contextptr); | 265 args.push_back(contextptr); |
267 } | 266 } |
268 else | 267 else |
269 { | 268 { |
352 } | 351 } |
353 else | 352 else |
354 call->setCallingConv(callconv); | 353 call->setCallingConv(callconv); |
355 call->setParamAttrs(palist); | 354 call->setParamAttrs(palist); |
356 | 355 |
357 return new DImValue(resulttype, retllval, false); | 356 return new DImValue(resulttype, retllval); |
358 } | 357 } |
359 | 358 |
360 | 359 |
361 | 360 |
362 | 361 |
363 | 362 |
364 | 363 |
365 | 364 |
366 | 365 |
367 | 366 |
368 | 367 |
369 | 368 |
370 | 369 |
371 | 370 |