Mercurial > projects > ldc
comparison gen/tocall.cpp @ 930:7985bb036db4
Follow the D ABI and pass the last arg in a register if it is a struct that fits.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 03 Feb 2009 21:46:46 +0100 |
parents | 162a0502a6b9 |
children | d3a6f1a96731 a904cc9bc064 |
comparison
equal
deleted
inserted
replaced
922:0749c0757a43 | 930:7985bb036db4 |
---|---|
368 Argument* fnarg = Argument::getNth(tf->parameters, i); | 368 Argument* fnarg = Argument::getNth(tf->parameters, i); |
369 assert(fnarg); | 369 assert(fnarg); |
370 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); | 370 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); |
371 LLValue* arg = argval->getRVal(); | 371 LLValue* arg = argval->getRVal(); |
372 | 372 |
373 // if it's a struct inreg arg, load first to pass as first-class value | |
374 if (tf->structInregArg && i == (tf->reverseParams ? n - 1 : 0)) | |
375 { | |
376 assert(fnarg->llvmAttrs & llvm::Attribute::InReg); | |
377 arg = DtoLoad(arg); | |
378 } | |
379 | |
373 int j = tf->reverseParams ? beg + n - i - 1 : beg + i; | 380 int j = tf->reverseParams ? beg + n - i - 1 : beg + i; |
374 | 381 |
375 // parameter type mismatch, this is hard to get rid of | 382 // parameter type mismatch, this is hard to get rid of |
376 if (arg->getType() != callableTy->getParamType(j)) | 383 if (arg->getType() != callableTy->getParamType(j)) |
377 { | 384 { |
393 } | 400 } |
394 | 401 |
395 // reverse the relevant params as well as the param attrs | 402 // reverse the relevant params as well as the param attrs |
396 if (tf->reverseParams) | 403 if (tf->reverseParams) |
397 { | 404 { |
398 std::reverse(args.begin() + tf->reverseIndex, args.end()); | 405 std::reverse(args.begin() + tf->firstRealArg, args.end()); |
399 std::reverse(attrptr.begin(), attrptr.end()); | 406 std::reverse(attrptr.begin(), attrptr.end()); |
400 } | 407 } |
401 | 408 |
402 // add attributes | 409 // add attributes |
403 for (int i = 0; i < n; i++) | 410 for (int i = 0; i < n; i++) |