comparison gen/toir.c @ 44:ea65e12b0dd0 trunk

[svn r48] fixed some storage problems
author lindquist
date Fri, 19 Oct 2007 16:05:06 +0200
parents 0b9b286b67b6
children 6d60e6049c4e
comparison
equal deleted inserted replaced
43:eb7bf7b7972e 44:ea65e12b0dd0
1025 1025
1026 // argument handling 1026 // argument handling
1027 llvm::FunctionType::param_iterator argiter = llfnty->param_begin(); 1027 llvm::FunctionType::param_iterator argiter = llfnty->param_begin();
1028 int j = 0; 1028 int j = 0;
1029 1029
1030 Logger::println("hidden struct return");
1031
1030 // hidden struct return arguments 1032 // hidden struct return arguments
1031 if (retinptr) { 1033 if (retinptr) {
1032 if (!p->lvals.empty()) { 1034 if (!p->lvals.empty() && p->toplval()) {
1033 assert(llvm::isa<llvm::StructType>(p->toplval()->getType()->getContainedType(0))); 1035 assert(llvm::isa<llvm::StructType>(p->toplval()->getType()->getContainedType(0)));
1034 llargs[j] = p->toplval(); 1036 llargs[j] = p->toplval();
1035 if (LLVM_DtoIsPassedByRef(tf->next)) { 1037 if (LLVM_DtoIsPassedByRef(tf->next)) {
1036 e->inplace = true; 1038 e->inplace = true;
1037 } 1039 }
1046 e->type = elem::VAR; 1048 e->type = elem::VAR;
1047 } 1049 }
1048 else { 1050 else {
1049 e->type = elem::VAL; 1051 e->type = elem::VAL;
1050 } 1052 }
1053
1054 Logger::println("this arguments");
1051 1055
1052 // this arguments 1056 // this arguments
1053 if (fn->arg) { 1057 if (fn->arg) {
1054 Logger::println("This Call"); 1058 Logger::println("This Call");
1055 if (fn->arg->getType() != argiter->get()) { 1059 if (fn->arg->getType() != argiter->get()) {
1068 llvm::Value* contextptr = LLVM_DtoGEP(fn->mem,zero,zero,"tmp",p->scopebb()); 1072 llvm::Value* contextptr = LLVM_DtoGEP(fn->mem,zero,zero,"tmp",p->scopebb());
1069 llargs[j] = new llvm::LoadInst(contextptr,"tmp",p->scopebb()); 1073 llargs[j] = new llvm::LoadInst(contextptr,"tmp",p->scopebb());
1070 ++j; 1074 ++j;
1071 ++argiter; 1075 ++argiter;
1072 } 1076 }
1077
1078 Logger::println("regular arguments");
1073 1079
1074 // regular arguments 1080 // regular arguments
1075 for (int i=0; i<arguments->dim; i++,j++) 1081 for (int i=0; i<arguments->dim; i++,j++)
1076 { 1082 {
1077 Argument* fnarg = Argument::getNth(tf->parameters, i); 1083 Argument* fnarg = Argument::getNth(tf->parameters, i);
1469 elem* e = new elem; 1475 elem* e = new elem;
1470 1476
1471 llvm::Value* sptr = 0; 1477 llvm::Value* sptr = 0;
1472 1478
1473 // if there is no lval, this is probably a temporary struct literal. correct? 1479 // if there is no lval, this is probably a temporary struct literal. correct?
1474 if (p->lvals.empty()) 1480 if (p->lvals.empty() || !p->toplval())
1475 { 1481 {
1476 sptr = new llvm::AllocaInst(LLVM_DtoType(type),"tmpstructliteral",p->topallocapoint()); 1482 sptr = new llvm::AllocaInst(LLVM_DtoType(type),"tmpstructliteral",p->topallocapoint());
1477 e->mem = sptr; 1483 e->mem = sptr;
1478 e->type = elem::VAR; 1484 e->type = elem::VAR;
1479 } 1485 }
2512 2518
2513 const llvm::Type* t = LLVM_DtoType(type); 2519 const llvm::Type* t = LLVM_DtoType(type);
2514 Logger::cout() << "array literal has llvm type: " << *t << '\n'; 2520 Logger::cout() << "array literal has llvm type: " << *t << '\n';
2515 2521
2516 llvm::Value* mem = 0; 2522 llvm::Value* mem = 0;
2517 if (p->lvals.empty()) { 2523 if (p->lvals.empty() || !p->toplval()) {
2518 assert(LLVM_DtoDType(type)->ty == Tsarray); 2524 assert(LLVM_DtoDType(type)->ty == Tsarray);
2519 mem = new llvm::AllocaInst(t,"tmparrayliteral",p->topallocapoint()); 2525 mem = new llvm::AllocaInst(t,"tmparrayliteral",p->topallocapoint());
2520 } 2526 }
2521 else { 2527 else {
2522 mem = p->toplval(); 2528 mem = p->toplval();