comparison gen/functions.cpp @ 939:cac9895be400

Automated merge with http://hg.dsource.org/projects/ldc
author Christian Kamm <kamm incasoftware de>
date Wed, 04 Feb 2009 18:39:39 +0100
parents b56f3571c450 a904cc9bc064
children 39519a1ff603
comparison
equal deleted inserted replaced
937:6c09179ebba0 939:cac9895be400
218 ) 218 )
219 { 219 {
220 arg->llvmAttrs |= llvm::Attribute::InReg; 220 arg->llvmAttrs |= llvm::Attribute::InReg;
221 assert((f->thisAttrs & llvm::Attribute::InReg) == 0 && "can't have two inreg args!"); 221 assert((f->thisAttrs & llvm::Attribute::InReg) == 0 && "can't have two inreg args!");
222 222
223 // structs need to go from {...}* byval to {...} inreg 223 // structs need to go from {...}* byval to i8/i16/i32 inreg
224 if ((arg->storageClass & STCin) && t->ty == Tstruct) 224 if ((arg->storageClass & STCin) && t->ty == Tstruct)
225 { 225 {
226 int n_param = f->reverseParams ? f->firstRealArg + n - 1 - n_inreg : f->firstRealArg + n_inreg; 226 int n_param = f->reverseParams ? f->firstRealArg + n - 1 - n_inreg : f->firstRealArg + n_inreg;
227 assert(isaPointer(paramvec[n_param]) && (arg->llvmAttrs & llvm::Attribute::ByVal) 227 assert(isaPointer(paramvec[n_param]) && (arg->llvmAttrs & llvm::Attribute::ByVal)
228 && "struct parameter expected to be {...}* byval before inreg is applied"); 228 && "struct parameter expected to be {...}* byval before inreg is applied");
229 paramvec[n_param] = paramvec[n_param]->getContainedType(0); 229 f->structInregArg = paramvec[n_param]->getContainedType(0);
230 paramvec[n_param] = LLIntegerType::get(8*t->size());
230 arg->llvmAttrs &= ~llvm::Attribute::ByVal; 231 arg->llvmAttrs &= ~llvm::Attribute::ByVal;
231 f->structInregArg = true;
232 } 232 }
233 } 233 }
234 } 234 }
235 } 235 }
236 } 236 }
761 761
762 // if it's inreg struct arg, allocate storage 762 // if it's inreg struct arg, allocate storage
763 if (f->structInregArg && i == (f->reverseParams ? n - 1 : 0)) 763 if (f->structInregArg && i == (f->reverseParams ? n - 1 : 0))
764 { 764 {
765 int n_param = f->reverseParams ? f->firstRealArg + n - 1 - i : f->firstRealArg + i; 765 int n_param = f->reverseParams ? f->firstRealArg + n - 1 - i : f->firstRealArg + i;
766 assert(!f->usesNest && !f->usesThis && isaStruct(functype->getParamType(n_param)) 766 const LLType* paramty = functype->getParamType(n_param);
767 assert(!f->usesNest && !f->usesThis &&
768 llvm::isa<LLIntegerType>(paramty) && isaStruct(f->structInregArg)
767 && "Preconditions for inreg struct arg not met!"); 769 && "Preconditions for inreg struct arg not met!");
768 770
769 LLValue* mem = DtoAlloca(functype->getParamType(n_param), "inregstructarg"); 771 LLValue* mem = DtoAlloca(f->structInregArg, "inregstructarg");
770 DtoStore(irloc->value, mem); 772
773 DtoStore(irloc->value, DtoBitCast(mem, getPtrToType(paramty)));
771 irloc->value = mem; 774 irloc->value = mem;
772 } 775 }
773 776
774 #if DMDV2 777 #if DMDV2
775 if (vd->nestedrefs.dim) 778 if (vd->nestedrefs.dim)