Mercurial > projects > ldc
comparison gen/tocall.cpp @ 454:283d113d4753
Added generation of the llvm 'sret' parameter attribute where applicable.
Fixed some wrong argument handling code when setting parameter attributes.
Updated the tango unittest script in the tango patch, does not work yet, all modules don't compile...
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 02 Aug 2008 02:54:57 +0200 |
parents | cc40db549aea |
children | b975f29b7256 |
comparison
equal
deleted
inserted
replaced
453:60332cd85308 | 454:283d113d4753 |
---|---|
211 | 211 |
212 // get llvm argument iterator, for types | 212 // get llvm argument iterator, for types |
213 LLFunctionType::param_iterator argbegin = callableTy->param_begin(); | 213 LLFunctionType::param_iterator argbegin = callableTy->param_begin(); |
214 LLFunctionType::param_iterator argiter = argbegin; | 214 LLFunctionType::param_iterator argiter = argbegin; |
215 | 215 |
216 // parameter attributes | |
217 llvm::PAListPtr palist; | |
218 | |
219 // return attrs | |
220 if (tf->llvmRetAttrs) | |
221 palist = palist.addAttr(0, tf->llvmRetAttrs); | |
222 | |
216 // handle implicit arguments | 223 // handle implicit arguments |
217 std::vector<LLValue*> args; | 224 std::vector<LLValue*> args; |
218 | 225 |
219 // return in hidden ptr is first | 226 // return in hidden ptr is first |
220 if (retinptr) | 227 if (retinptr) |
221 { | 228 { |
222 LLValue* retvar = new llvm::AllocaInst(argiter->get()->getContainedType(0), ".rettmp", gIR->topallocapoint()); | 229 LLValue* retvar = new llvm::AllocaInst(argiter->get()->getContainedType(0), ".rettmp", gIR->topallocapoint()); |
223 ++argiter; | 230 ++argiter; |
224 args.push_back(retvar); | 231 args.push_back(retvar); |
232 palist = palist.addAttr(1, llvm::ParamAttr::StructRet); | |
225 } | 233 } |
226 | 234 |
227 // then comes a context argument... | 235 // then comes a context argument... |
228 if(usesthis || delegatecall || nestedcall) | 236 if(usesthis || delegatecall || nestedcall) |
229 { | 237 { |
259 fatal(); | 267 fatal(); |
260 } | 268 } |
261 } | 269 } |
262 | 270 |
263 // handle the rest of the arguments based on param passing style | 271 // handle the rest of the arguments based on param passing style |
264 llvm::PAListPtr palist; | |
265 | |
266 if (tf->llvmRetAttrs) | |
267 palist = palist.addAttr(0, tf->llvmRetAttrs); | |
268 | 272 |
269 // variadic instrinsics need some custom casts | 273 // variadic instrinsics need some custom casts |
270 if (va_intrinsic) | 274 if (va_intrinsic) |
271 { | 275 { |
272 size_t n = arguments->dim; | 276 size_t n = arguments->dim; |
294 for (int i=0; i<arguments->dim; i++) { | 298 for (int i=0; i<arguments->dim; i++) { |
295 int j = argiter-argbegin; | 299 int j = argiter-argbegin; |
296 Argument* fnarg = Argument::getNth(tf->parameters, i); | 300 Argument* fnarg = Argument::getNth(tf->parameters, i); |
297 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); | 301 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); |
298 LLValue* arg = argval->getRVal(); | 302 LLValue* arg = argval->getRVal(); |
299 if (fnarg) | 303 if (fnarg) // can fnarg ever be null in this block? |
300 { | 304 { |
301 if (arg->getType() != callableTy->getParamType(j)) | 305 if (arg->getType() != callableTy->getParamType(j)) |
302 arg = DtoBitCast(arg, callableTy->getParamType(j)); | 306 arg = DtoBitCast(arg, callableTy->getParamType(j)); |
303 if (fnarg->llvmAttrs) | 307 if (fnarg->llvmAttrs) |
304 palist = palist.addAttr(j+1, fnarg->llvmAttrs); | 308 palist = palist.addAttr(j+1, fnarg->llvmAttrs); |