Mercurial > projects > ldc
comparison gen/arrays.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 | 76078c8ab5b9 |
children | a34078905d01 |
comparison
equal
deleted
inserted
replaced
478:b657298222d9 | 479:672eb4893b55 |
---|---|
116 LLValue* val; | 116 LLValue* val; |
117 | 117 |
118 // give slices and complex values storage (and thus an address to pass) | 118 // give slices and complex values storage (and thus an address to pass) |
119 if (value->isSlice() || value->isComplex()) | 119 if (value->isSlice() || value->isComplex()) |
120 { | 120 { |
121 val = new llvm::AllocaInst(DtoType(value->getType()), ".tmpparam", gIR->topallocapoint()); | 121 val = DtoAlloca(DtoType(value->getType()), ".tmpparam"); |
122 DVarValue lval(value->getType(), val, true); | 122 DVarValue lval(value->getType(), val, true); |
123 DtoAssign(loc, &lval, value); | 123 DtoAssign(loc, &lval, value); |
124 } | 124 } |
125 else | 125 else |
126 { | 126 { |
443 // get runtime function | 443 // get runtime function |
444 bool zeroInit = vtype->isZeroInit(); | 444 bool zeroInit = vtype->isZeroInit(); |
445 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_newarraymT" : "_d_newarraymiT" ); | 445 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_newarraymT" : "_d_newarraymiT" ); |
446 | 446 |
447 // build dims | 447 // build dims |
448 LLValue* dimsArg = new llvm::AllocaInst(DtoSize_t(), DtoConstUint(ndims), ".newdims", gIR->topallocapoint()); | 448 LLValue* dimsArg = DtoAlloca(DtoSize_t(), DtoConstUint(ndims), ".newdims"); |
449 LLValue* firstDim = NULL; | 449 LLValue* firstDim = NULL; |
450 for (size_t i=0; i<ndims; ++i) | 450 for (size_t i=0; i<ndims; ++i) |
451 { | 451 { |
452 LLValue* dim = dims[i]->getRVal(); | 452 LLValue* dim = dims[i]->getRVal(); |
453 if (!firstDim) firstDim = dim; | 453 if (!firstDim) firstDim = dim; |
696 | 696 |
697 Logger::println("giving storage"); | 697 Logger::println("giving storage"); |
698 | 698 |
699 // we need to give slices storage | 699 // we need to give slices storage |
700 if (l->isSlice()) { | 700 if (l->isSlice()) { |
701 lmem = new llvm::AllocaInst(DtoType(l->getType()), "tmpparam", gIR->topallocapoint()); | 701 lmem = DtoAlloca(DtoType(l->getType()), "tmpparam"); |
702 DtoSetArray(lmem, DtoArrayLen(l), DtoArrayPtr(l)); | 702 DtoSetArray(lmem, DtoArrayLen(l), DtoArrayPtr(l)); |
703 } | 703 } |
704 // also null | 704 // also null |
705 else if (l->isNull()) | 705 else if (l->isNull()) |
706 { | 706 { |
707 lmem = new llvm::AllocaInst(DtoType(l->getType()), "tmpparam", gIR->topallocapoint()); | 707 lmem = DtoAlloca(DtoType(l->getType()), "tmpparam"); |
708 DtoSetArray(lmem, llvm::Constant::getNullValue(DtoSize_t()), llvm::Constant::getNullValue(DtoType(l->getType()->next->pointerTo()))); | 708 DtoSetArray(lmem, llvm::Constant::getNullValue(DtoSize_t()), llvm::Constant::getNullValue(DtoType(l->getType()->next->pointerTo()))); |
709 } | 709 } |
710 else | 710 else |
711 lmem = l->getRVal(); | 711 lmem = l->getRVal(); |
712 | 712 |
713 // and for the rvalue ... | 713 // and for the rvalue ... |
714 // we need to give slices storage | 714 // we need to give slices storage |
715 if (r->isSlice()) { | 715 if (r->isSlice()) { |
716 rmem = new llvm::AllocaInst(DtoType(r->getType()), "tmpparam", gIR->topallocapoint()); | 716 rmem = DtoAlloca(DtoType(r->getType()), "tmpparam"); |
717 DtoSetArray(rmem, DtoArrayLen(r), DtoArrayPtr(r)); | 717 DtoSetArray(rmem, DtoArrayLen(r), DtoArrayPtr(r)); |
718 } | 718 } |
719 // also null | 719 // also null |
720 else if (r->isNull()) | 720 else if (r->isNull()) |
721 { | 721 { |
722 rmem = new llvm::AllocaInst(DtoType(r->getType()), "tmpparam", gIR->topallocapoint()); | 722 rmem = DtoAlloca(DtoType(r->getType()), "tmpparam"); |
723 DtoSetArray(rmem, llvm::Constant::getNullValue(DtoSize_t()), llvm::Constant::getNullValue(DtoType(r->getType()->next->pointerTo()))); | 723 DtoSetArray(rmem, llvm::Constant::getNullValue(DtoSize_t()), llvm::Constant::getNullValue(DtoType(r->getType()->next->pointerTo()))); |
724 } | 724 } |
725 else | 725 else |
726 rmem = r->getRVal(); | 726 rmem = r->getRVal(); |
727 | 727 |
1076 LLConstant* c = DtoConstString(loc.filename); | 1076 LLConstant* c = DtoConstString(loc.filename); |
1077 | 1077 |
1078 llvm::AllocaInst* alloc = gIR->func()->srcfileArg; | 1078 llvm::AllocaInst* alloc = gIR->func()->srcfileArg; |
1079 if (!alloc) | 1079 if (!alloc) |
1080 { | 1080 { |
1081 alloc = new llvm::AllocaInst(c->getType(), ".srcfile", gIR->topallocapoint()); | 1081 alloc = DtoAlloca(c->getType(), ".srcfile"); |
1082 gIR->func()->srcfileArg = alloc; | 1082 gIR->func()->srcfileArg = alloc; |
1083 } | 1083 } |
1084 LLValue* ptr = DtoGEPi(alloc, 0,0, "tmp"); | 1084 LLValue* ptr = DtoGEPi(alloc, 0,0, "tmp"); |
1085 DtoStore(c->getOperand(0), ptr); | 1085 DtoStore(c->getOperand(0), ptr); |
1086 ptr = DtoGEPi(alloc, 0,1, "tmp"); | 1086 ptr = DtoGEPi(alloc, 0,1, "tmp"); |