Mercurial > projects > ldc
comparison gen/functions.cpp @ 156:ccd07d9f2ce9 trunk
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
author | ChristianK |
---|---|
date | Thu, 01 May 2008 13:05:53 +0200 |
parents | 7f92f477ff53 |
children | 5c17f81fc1c1 |
comparison
equal
deleted
inserted
replaced
155:7f92f477ff53 | 156:ccd07d9f2ce9 |
---|---|
72 | 72 |
73 if (typesafeVararg) { | 73 if (typesafeVararg) { |
74 ClassDeclaration* ti = Type::typeinfo; | 74 ClassDeclaration* ti = Type::typeinfo; |
75 ti->toObjFile(); | 75 ti->toObjFile(); |
76 DtoForceConstInitDsymbol(ti); | 76 DtoForceConstInitDsymbol(ti); |
77 assert(ti->irStruct->constInit); | 77 assert(gIR->irDsymbol[ti].irStruct->constInit); |
78 std::vector<const llvm::Type*> types; | 78 std::vector<const llvm::Type*> types; |
79 types.push_back(DtoSize_t()); | 79 types.push_back(DtoSize_t()); |
80 types.push_back(getPtrToType(getPtrToType(ti->irStruct->constInit->getType()))); | 80 types.push_back(getPtrToType(getPtrToType(gIR->irDsymbol[ti].irStruct->constInit->getType()))); |
81 const llvm::Type* t1 = llvm::StructType::get(types); | 81 const llvm::Type* t1 = llvm::StructType::get(types); |
82 paramvec.push_back(getPtrToType(t1)); | 82 paramvec.push_back(getPtrToType(t1)); |
83 paramvec.push_back(getPtrToType(llvm::Type::Int8Ty)); | 83 paramvec.push_back(getPtrToType(llvm::Type::Int8Ty)); |
84 } | 84 } |
85 | 85 |
230 assert(0); | 230 assert(0); |
231 | 231 |
232 llvm::Function* func = llvm::dyn_cast<llvm::Function>(fn); | 232 llvm::Function* func = llvm::dyn_cast<llvm::Function>(fn); |
233 assert(func); | 233 assert(func); |
234 assert(func->isIntrinsic()); | 234 assert(func->isIntrinsic()); |
235 gIR->irFunc[fdecl]->func = func; | 235 gIR->irDsymbol[fdecl].irFunc->func = func; |
236 return func; | 236 return func; |
237 } | 237 } |
238 | 238 |
239 ////////////////////////////////////////////////////////////////////////////////////////// | 239 ////////////////////////////////////////////////////////////////////////////////////////// |
240 | 240 |
249 { | 249 { |
250 if (fdecl->prot() == PROTprivate) | 250 if (fdecl->prot() == PROTprivate) |
251 return; | 251 return; |
252 } | 252 } |
253 | 253 |
254 if (fdecl->llvmResolved) return; | 254 if (gIR->irDsymbol[fdecl].resolved) return; |
255 fdecl->llvmResolved = true; | 255 gIR->irDsymbol[fdecl].resolved = true; |
256 | 256 |
257 Logger::println("DtoResolveFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars()); | 257 Logger::println("DtoResolveFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars()); |
258 LOG_SCOPE; | 258 LOG_SCOPE; |
259 | 259 |
260 if (fdecl->runTimeHack) { | 260 if (fdecl->runTimeHack) { |
270 TemplateDeclaration* tempdecl = tinst->tempdecl; | 270 TemplateDeclaration* tempdecl = tinst->tempdecl; |
271 if (tempdecl->llvmInternal == LLVMva_arg) | 271 if (tempdecl->llvmInternal == LLVMva_arg) |
272 { | 272 { |
273 Logger::println("magic va_arg found"); | 273 Logger::println("magic va_arg found"); |
274 fdecl->llvmInternal = LLVMva_arg; | 274 fdecl->llvmInternal = LLVMva_arg; |
275 fdecl->llvmDeclared = true; | 275 gIR->irDsymbol[fdecl].declared = true; |
276 fdecl->llvmInitialized = true; | 276 gIR->irDsymbol[fdecl].initialized = true; |
277 fdecl->llvmDefined = true; | 277 gIR->irDsymbol[fdecl].defined = true; |
278 return; // this gets mapped to an instruction so a declaration makes no sence | 278 return; // this gets mapped to an instruction so a declaration makes no sence |
279 } | 279 } |
280 else if (tempdecl->llvmInternal == LLVMva_start) | 280 else if (tempdecl->llvmInternal == LLVMva_start) |
281 { | 281 { |
282 Logger::println("magic va_start found"); | 282 Logger::println("magic va_start found"); |
293 | 293 |
294 ////////////////////////////////////////////////////////////////////////////////////////// | 294 ////////////////////////////////////////////////////////////////////////////////////////// |
295 | 295 |
296 void DtoDeclareFunction(FuncDeclaration* fdecl) | 296 void DtoDeclareFunction(FuncDeclaration* fdecl) |
297 { | 297 { |
298 if (fdecl->llvmDeclared) return; | 298 if (gIR->irDsymbol[fdecl].declared) return; |
299 fdecl->llvmDeclared = true; | 299 gIR->irDsymbol[fdecl].declared = true; |
300 | 300 |
301 Logger::println("DtoDeclareFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars()); | 301 Logger::println("DtoDeclareFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars()); |
302 LOG_SCOPE; | 302 LOG_SCOPE; |
303 | 303 |
304 assert(!fdecl->isAbstract()); | 304 assert(!fdecl->isAbstract()); |
309 fatal(); | 309 fatal(); |
310 } | 310 } |
311 | 311 |
312 if (fdecl->runTimeHack) { | 312 if (fdecl->runTimeHack) { |
313 Logger::println("runtime hack func chars: %s", fdecl->toChars()); | 313 Logger::println("runtime hack func chars: %s", fdecl->toChars()); |
314 if (gIR->irFunc.find(fdecl) == gIR->irFunc.end()) { | 314 if (!gIR->irDsymbol[fdecl].irFunc) { |
315 gIR->irFunc[fdecl] = new IrFunction(fdecl); | 315 gIR->irDsymbol[fdecl].irFunc = new IrFunction(fdecl); |
316 gIR->irFunc[fdecl]->func = LLVM_D_GetRuntimeFunction(gIR->module, fdecl->toChars()); | 316 gIR->irDsymbol[fdecl].irFunc->func = LLVM_D_GetRuntimeFunction(gIR->module, fdecl->toChars()); |
317 } | 317 } |
318 return; | 318 return; |
319 } | 319 } |
320 | 320 |
321 bool declareOnly = false; | 321 bool declareOnly = false; |
328 declareOnly = true; | 328 declareOnly = true; |
329 } | 329 } |
330 else if (fdecl->llvmInternal == LLVMva_start) | 330 else if (fdecl->llvmInternal == LLVMva_start) |
331 declareOnly = true; | 331 declareOnly = true; |
332 | 332 |
333 if (gIR->irFunc.find(fdecl) == gIR->irFunc.end()) { | 333 if (!gIR->irDsymbol[fdecl].irFunc) { |
334 gIR->irFunc[fdecl] = new IrFunction(fdecl); | 334 gIR->irDsymbol[fdecl].irFunc = new IrFunction(fdecl); |
335 } | 335 } |
336 | 336 |
337 // mangled name | 337 // mangled name |
338 char* mangled_name; | 338 char* mangled_name; |
339 if (fdecl->llvmInternal == LLVMintrinsic) | 339 if (fdecl->llvmInternal == LLVMintrinsic) |
356 func = new llvm::Function(functype, DtoLinkage(fdecl), mangled_name, gIR->module); | 356 func = new llvm::Function(functype, DtoLinkage(fdecl), mangled_name, gIR->module); |
357 else | 357 else |
358 assert(func->getFunctionType() == functype); | 358 assert(func->getFunctionType() == functype); |
359 | 359 |
360 // add func to IRFunc | 360 // add func to IRFunc |
361 gIR->irFunc[fdecl]->func = func; | 361 gIR->irDsymbol[fdecl].irFunc->func = func; |
362 | 362 |
363 // calling convention | 363 // calling convention |
364 if (!vafunc && fdecl->llvmInternal != LLVMintrinsic) | 364 if (!vafunc && fdecl->llvmInternal != LLVMintrinsic) |
365 func->setCallingConv(DtoCallingConv(f->linkage)); | 365 func->setCallingConv(DtoCallingConv(f->linkage)); |
366 else // fall back to C, it should be the right thing to do | 366 else // fall back to C, it should be the right thing to do |
367 func->setCallingConv(llvm::CallingConv::C); | 367 func->setCallingConv(llvm::CallingConv::C); |
368 | 368 |
369 gIR->irFunc[fdecl]->func = func; | 369 gIR->irDsymbol[fdecl].irFunc->func = func; |
370 assert(llvm::isa<llvm::FunctionType>(f->llvmType->get())); | 370 assert(llvm::isa<llvm::FunctionType>(f->llvmType->get())); |
371 | 371 |
372 // main | 372 // main |
373 if (fdecl->isMain()) { | 373 if (fdecl->isMain()) { |
374 gIR->mainFunc = func; | 374 gIR->mainFunc = func; |
386 // name parameters | 386 // name parameters |
387 llvm::Function::arg_iterator iarg = func->arg_begin(); | 387 llvm::Function::arg_iterator iarg = func->arg_begin(); |
388 int k = 0; | 388 int k = 0; |
389 if (f->llvmRetInPtr) { | 389 if (f->llvmRetInPtr) { |
390 iarg->setName("retval"); | 390 iarg->setName("retval"); |
391 gIR->irFunc[fdecl]->retArg = iarg; | 391 gIR->irDsymbol[fdecl].irFunc->retArg = iarg; |
392 ++iarg; | 392 ++iarg; |
393 } | 393 } |
394 if (f->llvmUsesThis) { | 394 if (f->llvmUsesThis) { |
395 iarg->setName("this"); | 395 iarg->setName("this"); |
396 gIR->irFunc[fdecl]->thisVar = iarg; | 396 gIR->irDsymbol[fdecl].irFunc->thisVar = iarg; |
397 assert(gIR->irFunc[fdecl]->thisVar); | 397 assert(gIR->irDsymbol[fdecl].irFunc->thisVar); |
398 ++iarg; | 398 ++iarg; |
399 } | 399 } |
400 | 400 |
401 if (f->linkage == LINKd && f->varargs == 1) { | 401 if (f->linkage == LINKd && f->varargs == 1) { |
402 iarg->setName("_arguments"); | 402 iarg->setName("_arguments"); |
403 gIR->irFunc[fdecl]->_arguments = iarg; | 403 gIR->irDsymbol[fdecl].irFunc->_arguments = iarg; |
404 ++iarg; | 404 ++iarg; |
405 iarg->setName("_argptr"); | 405 iarg->setName("_argptr"); |
406 gIR->irFunc[fdecl]->_argptr = iarg; | 406 gIR->irDsymbol[fdecl].irFunc->_argptr = iarg; |
407 ++iarg; | 407 ++iarg; |
408 } | 408 } |
409 | 409 |
410 for (; iarg != func->arg_end(); ++iarg) | 410 for (; iarg != func->arg_end(); ++iarg) |
411 { | 411 { |
412 Argument* arg = Argument::getNth(f->parameters, k++); | 412 Argument* arg = Argument::getNth(f->parameters, k++); |
413 //arg->llvmValue = iarg; | 413 //arg->llvmValue = iarg; |
414 //Logger::println("identifier: '%s' %p\n", arg->ident->toChars(), arg->ident); | 414 //Logger::println("identifier: '%s' %p\n", arg->ident->toChars(), arg->ident); |
415 if (arg && arg->ident != 0) { | 415 if (arg && arg->ident != 0) { |
416 if (arg->vardecl) { | 416 if (arg->vardecl) { |
417 if (arg->vardecl->irLocal) | 417 if (gIR->irDsymbol[arg->vardecl].irLocal) |
418 { | 418 { |
419 Logger::cout() << "WTF!?!: " << *arg->vardecl->irLocal->value << '\n'; | 419 Logger::cout() << "WTF!?!: " << *gIR->irDsymbol[arg->vardecl].irLocal->value << '\n'; |
420 } | 420 } |
421 assert(!arg->vardecl->irLocal); | 421 assert(!gIR->irDsymbol[arg->vardecl].irLocal); |
422 assert(!arg->vardecl->irGlobal); | 422 assert(!gIR->irDsymbol[arg->vardecl].irGlobal); |
423 assert(!arg->vardecl->irField); | 423 assert(!gIR->irDsymbol[arg->vardecl].irField); |
424 arg->vardecl->irLocal = new IrLocal(arg->vardecl); | 424 gIR->irDsymbol[arg->vardecl].irLocal = new IrLocal(arg->vardecl); |
425 arg->vardecl->irLocal->value = iarg; | 425 gIR->irDsymbol[arg->vardecl].irLocal->value = iarg; |
426 } | 426 } |
427 iarg->setName(arg->ident->toChars()); | 427 iarg->setName(arg->ident->toChars()); |
428 } | 428 } |
429 else { | 429 else { |
430 iarg->setName("unnamed"); | 430 iarg->setName("unnamed"); |
444 | 444 |
445 ////////////////////////////////////////////////////////////////////////////////////////// | 445 ////////////////////////////////////////////////////////////////////////////////////////// |
446 | 446 |
447 void DtoDefineFunc(FuncDeclaration* fd) | 447 void DtoDefineFunc(FuncDeclaration* fd) |
448 { | 448 { |
449 if (fd->llvmDefined) return; | 449 if (gIR->irDsymbol[fd].defined) return; |
450 fd->llvmDefined = true; | 450 gIR->irDsymbol[fd].defined = true; |
451 | 451 |
452 assert(fd->llvmDeclared); | 452 assert(gIR->irDsymbol[fd].declared); |
453 | 453 |
454 Logger::println("DtoDefineFunc(%s): %s", fd->toPrettyChars(), fd->loc.toChars()); | 454 Logger::println("DtoDefineFunc(%s): %s", fd->toPrettyChars(), fd->loc.toChars()); |
455 LOG_SCOPE; | 455 LOG_SCOPE; |
456 | 456 |
457 // debug info | 457 // debug info |
458 if (global.params.symdebug) { | 458 if (global.params.symdebug) { |
459 Module* mo = fd->getModule(); | 459 Module* mo = fd->getModule(); |
460 gIR->irFunc[fd]->dwarfSubProg = DtoDwarfSubProgram(fd, DtoDwarfCompileUnit(mo)); | 460 gIR->irDsymbol[fd].irFunc->dwarfSubProg = DtoDwarfSubProgram(fd, DtoDwarfCompileUnit(mo)); |
461 } | 461 } |
462 | 462 |
463 Type* t = DtoDType(fd->type); | 463 Type* t = DtoDType(fd->type); |
464 TypeFunction* f = (TypeFunction*)t; | 464 TypeFunction* f = (TypeFunction*)t; |
465 assert(f->llvmType); | 465 assert(f->llvmType); |
466 | 466 |
467 llvm::Function* func = gIR->irFunc[fd]->func; | 467 llvm::Function* func = gIR->irDsymbol[fd].irFunc->func; |
468 const llvm::FunctionType* functype = func->getFunctionType(); | 468 const llvm::FunctionType* functype = func->getFunctionType(); |
469 | 469 |
470 // only members of the current module or template instances maybe be defined | 470 // only members of the current module or template instances maybe be defined |
471 if (fd->getModule() == gIR->dmodule || DtoIsTemplateInstance(fd->parent)) | 471 if (fd->getModule() == gIR->dmodule || DtoIsTemplateInstance(fd->parent)) |
472 { | 472 { |
473 fd->llvmDModule = gIR->dmodule; | 473 gIR->irDsymbol[fd].DModule = gIR->dmodule; |
474 | 474 |
475 // function definition | 475 // function definition |
476 if (fd->fbody != 0) | 476 if (fd->fbody != 0) |
477 { | 477 { |
478 Logger::println("Doing function body for: %s", fd->toChars()); | 478 Logger::println("Doing function body for: %s", fd->toChars()); |
479 assert(gIR->irFunc.count(fd) != 0); | 479 assert(gIR->irDsymbol[fd].irFunc); |
480 gIR->functions.push_back(gIR->irFunc[fd]); | 480 gIR->functions.push_back(gIR->irDsymbol[fd].irFunc); |
481 | 481 |
482 if (fd->isMain()) | 482 if (fd->isMain()) |
483 gIR->emitMain = true; | 483 gIR->emitMain = true; |
484 | 484 |
485 llvm::BasicBlock* beginbb = new llvm::BasicBlock("entry",func); | 485 llvm::BasicBlock* beginbb = new llvm::BasicBlock("entry",func); |
493 gIR->func()->allocapoint = allocaPoint; | 493 gIR->func()->allocapoint = allocaPoint; |
494 | 494 |
495 // need result variable? (not nested) | 495 // need result variable? (not nested) |
496 if (fd->vresult && !fd->vresult->nestedref) { | 496 if (fd->vresult && !fd->vresult->nestedref) { |
497 Logger::println("non-nested vresult value"); | 497 Logger::println("non-nested vresult value"); |
498 fd->vresult->irLocal = new IrLocal(fd->vresult); | 498 gIR->irDsymbol[fd->vresult].irLocal = new IrLocal(fd->vresult); |
499 fd->vresult->irLocal->value = new llvm::AllocaInst(DtoType(fd->vresult->type),"function_vresult",allocaPoint); | 499 gIR->irDsymbol[fd->vresult].irLocal->value = new llvm::AllocaInst(DtoType(fd->vresult->type),"function_vresult",allocaPoint); |
500 } | 500 } |
501 | 501 |
502 // give arguments storage | 502 // give arguments storage |
503 size_t n = Argument::dim(f->parameters); | 503 size_t n = Argument::dim(f->parameters); |
504 for (int i=0; i < n; ++i) { | 504 for (int i=0; i < n; ++i) { |
505 Argument* arg = Argument::getNth(f->parameters, i); | 505 Argument* arg = Argument::getNth(f->parameters, i); |
506 if (arg && arg->vardecl) { | 506 if (arg && arg->vardecl) { |
507 VarDeclaration* vd = arg->vardecl; | 507 VarDeclaration* vd = arg->vardecl; |
508 if (!vd->needsStorage || vd->nestedref || vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type)) | 508 if (!vd->needsStorage || vd->nestedref || vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type)) |
509 continue; | 509 continue; |
510 llvm::Value* a = vd->irLocal->value; | 510 llvm::Value* a = gIR->irDsymbol[vd].irLocal->value; |
511 assert(a); | 511 assert(a); |
512 std::string s(a->getName()); | 512 std::string s(a->getName()); |
513 Logger::println("giving argument '%s' storage", s.c_str()); | 513 Logger::println("giving argument '%s' storage", s.c_str()); |
514 s.append("_storage"); | 514 s.append("_storage"); |
515 llvm::Value* v = new llvm::AllocaInst(a->getType(),s,allocaPoint); | 515 llvm::Value* v = new llvm::AllocaInst(a->getType(),s,allocaPoint); |
516 gIR->ir->CreateStore(a,v); | 516 gIR->ir->CreateStore(a,v); |
517 vd->irLocal->value = v; | 517 gIR->irDsymbol[vd].irLocal->value = v; |
518 } | 518 } |
519 else { | 519 else { |
520 Logger::attention(fd->loc, "some unknown argument: %s", arg ? arg->toChars() : 0); | 520 Logger::attention(fd->loc, "some unknown argument: %s", arg ? arg->toChars() : 0); |
521 } | 521 } |
522 } | 522 } |
525 if (global.params.symdebug) DtoDwarfFuncStart(fd); | 525 if (global.params.symdebug) DtoDwarfFuncStart(fd); |
526 | 526 |
527 llvm::Value* parentNested = NULL; | 527 llvm::Value* parentNested = NULL; |
528 if (FuncDeclaration* fd2 = fd->toParent2()->isFuncDeclaration()) { | 528 if (FuncDeclaration* fd2 = fd->toParent2()->isFuncDeclaration()) { |
529 if (!fd->isStatic()) // huh? | 529 if (!fd->isStatic()) // huh? |
530 parentNested = gIR->irFunc[fd2]->nestedVar; | 530 parentNested = gIR->irDsymbol[fd2].irFunc->nestedVar; |
531 } | 531 } |
532 | 532 |
533 // need result variable? (nested) | 533 // need result variable? (nested) |
534 if (fd->vresult && fd->vresult->nestedref) { | 534 if (fd->vresult && fd->vresult->nestedref) { |
535 Logger::println("nested vresult value: %s", fd->vresult->toChars()); | 535 Logger::println("nested vresult value: %s", fd->vresult->toChars()); |
545 j++; | 545 j++; |
546 } | 546 } |
547 for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i) { | 547 for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i) { |
548 VarDeclaration* vd = *i; | 548 VarDeclaration* vd = *i; |
549 Logger::println("referenced nested variable %s", vd->toChars()); | 549 Logger::println("referenced nested variable %s", vd->toChars()); |
550 if (!vd->irLocal) | 550 if (!gIR->irDsymbol[vd].irLocal) |
551 vd->irLocal = new IrLocal(vd); | 551 gIR->irDsymbol[vd].irLocal = new IrLocal(vd); |
552 vd->irLocal->nestedIndex = j++; | 552 gIR->irDsymbol[vd].irLocal->nestedIndex = j++; |
553 if (vd->isParameter()) { | 553 if (vd->isParameter()) { |
554 if (!vd->irLocal->value) { | 554 if (!gIR->irDsymbol[vd].irLocal->value) { |
555 assert(vd == fd->vthis); | 555 assert(vd == fd->vthis); |
556 vd->irLocal->value = gIR->irFunc[fd]->thisVar; | 556 gIR->irDsymbol[vd].irLocal->value = gIR->irDsymbol[fd].irFunc->thisVar; |
557 } | 557 } |
558 assert(vd->irLocal->value); | 558 assert(gIR->irDsymbol[vd].irLocal->value); |
559 nestTypes.push_back(vd->irLocal->value->getType()); | 559 nestTypes.push_back(gIR->irDsymbol[vd].irLocal->value->getType()); |
560 } | 560 } |
561 else { | 561 else { |
562 nestTypes.push_back(DtoType(vd->type)); | 562 nestTypes.push_back(DtoType(vd->type)); |
563 } | 563 } |
564 } | 564 } |
565 const llvm::StructType* nestSType = llvm::StructType::get(nestTypes); | 565 const llvm::StructType* nestSType = llvm::StructType::get(nestTypes); |
566 Logger::cout() << "nested var struct has type:" << *nestSType << '\n'; | 566 Logger::cout() << "nested var struct has type:" << *nestSType << '\n'; |
567 gIR->irFunc[fd]->nestedVar = new llvm::AllocaInst(nestSType,"nestedvars",allocaPoint); | 567 gIR->irDsymbol[fd].irFunc->nestedVar = new llvm::AllocaInst(nestSType,"nestedvars",allocaPoint); |
568 if (parentNested) { | 568 if (parentNested) { |
569 assert(gIR->irFunc[fd]->thisVar); | 569 assert(gIR->irDsymbol[fd].irFunc->thisVar); |
570 llvm::Value* ptr = gIR->ir->CreateBitCast(gIR->irFunc[fd]->thisVar, parentNested->getType(), "tmp"); | 570 llvm::Value* ptr = gIR->ir->CreateBitCast(gIR->irDsymbol[fd].irFunc->thisVar, parentNested->getType(), "tmp"); |
571 gIR->ir->CreateStore(ptr, DtoGEPi(gIR->irFunc[fd]->nestedVar, 0,0, "tmp")); | 571 gIR->ir->CreateStore(ptr, DtoGEPi(gIR->irDsymbol[fd].irFunc->nestedVar, 0,0, "tmp")); |
572 } | 572 } |
573 for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i) { | 573 for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i) { |
574 VarDeclaration* vd = *i; | 574 VarDeclaration* vd = *i; |
575 if (vd->isParameter()) { | 575 if (vd->isParameter()) { |
576 assert(vd->irLocal); | 576 assert(gIR->irDsymbol[vd].irLocal); |
577 gIR->ir->CreateStore(vd->irLocal->value, DtoGEPi(gIR->irFunc[fd]->nestedVar, 0, vd->irLocal->nestedIndex, "tmp")); | 577 gIR->ir->CreateStore(gIR->irDsymbol[vd].irLocal->value, DtoGEPi(gIR->irDsymbol[fd].irFunc->nestedVar, 0, gIR->irDsymbol[vd].irLocal->nestedIndex, "tmp")); |
578 vd->irLocal->value = gIR->irFunc[fd]->nestedVar; | 578 gIR->irDsymbol[vd].irLocal->value = gIR->irDsymbol[fd].irFunc->nestedVar; |
579 } | 579 } |
580 } | 580 } |
581 } | 581 } |
582 | 582 |
583 // copy _argptr to a memory location | 583 // copy _argptr to a memory location |
584 if (f->linkage == LINKd && f->varargs == 1) | 584 if (f->linkage == LINKd && f->varargs == 1) |
585 { | 585 { |
586 llvm::Value* argptrmem = new llvm::AllocaInst(gIR->irFunc[fd]->_argptr->getType(), "_argptrmem", gIR->topallocapoint()); | 586 llvm::Value* argptrmem = new llvm::AllocaInst(gIR->irDsymbol[fd].irFunc->_argptr->getType(), "_argptrmem", gIR->topallocapoint()); |
587 new llvm::StoreInst(gIR->irFunc[fd]->_argptr, argptrmem, gIR->scopebb()); | 587 new llvm::StoreInst(gIR->irDsymbol[fd].irFunc->_argptr, argptrmem, gIR->scopebb()); |
588 gIR->irFunc[fd]->_argptr = argptrmem; | 588 gIR->irDsymbol[fd].irFunc->_argptr = argptrmem; |
589 } | 589 } |
590 | 590 |
591 // output function body | 591 // output function body |
592 fd->fbody->toIR(gIR); | 592 fd->fbody->toIR(gIR); |
593 | 593 |