comparison gen/functions.cpp @ 479:672eb4893b55

Move AllocaInst creation into DtoAlloca helper. Will enable special zero-init of fp80 reals' padding.
author Christian Kamm <kamm incasoftware de>
date Tue, 05 Aug 2008 19:28:19 +0200
parents 45a67b6f1310
children a34078905d01
comparison
equal deleted inserted replaced
478:b657298222d9 479:672eb4893b55
570 570
571 // need result variable? (not nested) 571 // need result variable? (not nested)
572 if (fd->vresult && !fd->vresult->nestedref) { 572 if (fd->vresult && !fd->vresult->nestedref) {
573 Logger::println("non-nested vresult value"); 573 Logger::println("non-nested vresult value");
574 fd->vresult->ir.irLocal = new IrLocal(fd->vresult); 574 fd->vresult->ir.irLocal = new IrLocal(fd->vresult);
575 fd->vresult->ir.irLocal->value = new llvm::AllocaInst(DtoType(fd->vresult->type),"function_vresult",allocaPoint); 575 fd->vresult->ir.irLocal->value = DtoAlloca(DtoType(fd->vresult->type),"function_vresult");
576 } 576 }
577 577
578 // give the 'this' argument storage and debug info 578 // give the 'this' argument storage and debug info
579 // only if not referenced by nested functions 579 // only if not referenced by nested functions
580 if (fd->needThis() && !fd->vthis->nestedref) 580 if (fd->needThis() && !fd->vthis->nestedref)
581 { 581 {
582 LLValue* thisvar = irfunction->thisVar; 582 LLValue* thisvar = irfunction->thisVar;
583 assert(thisvar); 583 assert(thisvar);
584 584
585 LLValue* thismem = new llvm::AllocaInst(thisvar->getType(), ".newthis", allocaPoint); 585 LLValue* thismem = DtoAlloca(thisvar->getType(), ".newthis");
586 DtoStore(thisvar, thismem); 586 DtoStore(thisvar, thismem);
587 irfunction->thisVar = thismem; 587 irfunction->thisVar = thismem;
588 588
589 if (global.params.symdebug) 589 if (global.params.symdebug)
590 DtoDwarfLocalVariable(thismem, fd->vthis); 590 DtoDwarfLocalVariable(thismem, fd->vthis);
617 DtoDwarfLocalVariable(vdirval, vd); 617 DtoDwarfLocalVariable(vdirval, vd);
618 continue; 618 continue;
619 } 619 }
620 620
621 LLValue* a = irloc->value; 621 LLValue* a = irloc->value;
622 LLValue* v = new llvm::AllocaInst(a->getType(), "."+a->getName(), allocaPoint); 622 LLValue* v = DtoAlloca(a->getType(), "."+a->getName());
623 DtoStore(a,v); 623 DtoStore(a,v);
624 irloc->value = v; 624 irloc->value = v;
625 } 625 }
626 } 626 }
627 627
663 nestTypes.push_back(DtoType(vd->type)); 663 nestTypes.push_back(DtoType(vd->type));
664 } 664 }
665 } 665 }
666 const llvm::StructType* nestSType = llvm::StructType::get(nestTypes); 666 const llvm::StructType* nestSType = llvm::StructType::get(nestTypes);
667 Logger::cout() << "nested var struct has type:" << *nestSType << '\n'; 667 Logger::cout() << "nested var struct has type:" << *nestSType << '\n';
668 fd->ir.irFunc->nestedVar = new llvm::AllocaInst(nestSType,"nestedvars",allocaPoint); 668 fd->ir.irFunc->nestedVar = DtoAlloca(nestSType,"nestedvars");
669 if (parentNested) { 669 if (parentNested) {
670 assert(fd->ir.irFunc->thisVar); 670 assert(fd->ir.irFunc->thisVar);
671 LLValue* ptr = gIR->ir->CreateBitCast(fd->ir.irFunc->thisVar, parentNested->getType(), "tmp"); 671 LLValue* ptr = gIR->ir->CreateBitCast(fd->ir.irFunc->thisVar, parentNested->getType(), "tmp");
672 gIR->ir->CreateStore(ptr, DtoGEPi(fd->ir.irFunc->nestedVar, 0,0, "tmp")); 672 gIR->ir->CreateStore(ptr, DtoGEPi(fd->ir.irFunc->nestedVar, 0,0, "tmp"));
673 } 673 }
682 } 682 }
683 683
684 // copy _argptr to a memory location 684 // copy _argptr to a memory location
685 if (f->linkage == LINKd && f->varargs == 1) 685 if (f->linkage == LINKd && f->varargs == 1)
686 { 686 {
687 LLValue* argptrmem = new llvm::AllocaInst(fd->ir.irFunc->_argptr->getType(), "_argptrmem", gIR->topallocapoint()); 687 LLValue* argptrmem = DtoAlloca(fd->ir.irFunc->_argptr->getType(), "_argptrmem");
688 new llvm::StoreInst(fd->ir.irFunc->_argptr, argptrmem, gIR->scopebb()); 688 new llvm::StoreInst(fd->ir.irFunc->_argptr, argptrmem, gIR->scopebb());
689 fd->ir.irFunc->_argptr = argptrmem; 689 fd->ir.irFunc->_argptr = argptrmem;
690 } 690 }
691 691
692 // output function body 692 // output function body
789 arg = new DImValue(argexp->type, arg->getRVal(), false); 789 arg = new DImValue(argexp->type, arg->getRVal(), false);
790 } 790 }
791 // byval arg, but expr has no storage yet 791 // byval arg, but expr has no storage yet
792 else if (DtoIsPassedByRef(argexp->type) && (arg->isSlice() || arg->isComplex() || arg->isNull())) 792 else if (DtoIsPassedByRef(argexp->type) && (arg->isSlice() || arg->isComplex() || arg->isNull()))
793 { 793 {
794 LLValue* alloc = new llvm::AllocaInst(DtoType(argexp->type), "tmpparam", gIR->topallocapoint()); 794 LLValue* alloc = DtoAlloca(DtoType(argexp->type), "tmpparam");
795 DVarValue* vv = new DVarValue(argexp->type, alloc, true); 795 DVarValue* vv = new DVarValue(argexp->type, alloc, true);
796 DtoAssign(argexp->loc, vv, arg); 796 DtoAssign(argexp->loc, vv, arg);
797 arg = vv; 797 arg = vv;
798 } 798 }
799 799