Mercurial > projects > ldc
comparison gen/tocall.cpp @ 715:30b42a283c8e
Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:55:33 +0200 |
parents | df196c8dea26 |
children | 7261ff0f95ff |
comparison
equal
deleted
inserted
replaced
714:1e98c99a87cb | 715:30b42a283c8e |
---|---|
173 tiinits = llvm::ConstantStruct::get(pinits); | 173 tiinits = llvm::ConstantStruct::get(pinits); |
174 LLValue* typeinfoarrayparam = new llvm::GlobalVariable(tiarrty, | 174 LLValue* typeinfoarrayparam = new llvm::GlobalVariable(tiarrty, |
175 true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array", gIR->module); | 175 true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array", gIR->module); |
176 | 176 |
177 // specify arguments | 177 // specify arguments |
178 args.push_back(typeinfoarrayparam); | 178 args.push_back(DtoLoad(typeinfoarrayparam)); |
179 ++argidx; | 179 ++argidx; |
180 args.push_back(gIR->ir->CreateBitCast(mem, getPtrToType(LLType::Int8Ty), "tmp")); | 180 args.push_back(gIR->ir->CreateBitCast(mem, getPtrToType(LLType::Int8Ty), "tmp")); |
181 ++argidx; | 181 ++argidx; |
182 | 182 |
183 // pass non variadic args | 183 // pass non variadic args |
317 Argument* fnarg = Argument::getNth(tf->parameters, i); | 317 Argument* fnarg = Argument::getNth(tf->parameters, i); |
318 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); | 318 DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]); |
319 LLValue* arg = argval->getRVal(); | 319 LLValue* arg = argval->getRVal(); |
320 if (fnarg) // can fnarg ever be null in this block? | 320 if (fnarg) // can fnarg ever be null in this block? |
321 { | 321 { |
322 // if (Logger::enabled()) | 322 if (Logger::enabled()) |
323 // { | 323 { |
324 // Logger::cout() << "arg: " << *arg << '\n'; | 324 Logger::cout() << "arg: " << *arg << '\n'; |
325 // Logger::cout() << "expects: " << *callableTy->getParamType(j) << '\n'; | 325 Logger::cout() << "expects: " << *callableTy->getParamType(j) << '\n'; |
326 // } | 326 } |
327 if (arg->getType() != callableTy->getParamType(j)) | 327 if (arg->getType() != callableTy->getParamType(j)) |
328 arg = DtoBitCast(arg, callableTy->getParamType(j)); | 328 arg = DtoBitCast(arg, callableTy->getParamType(j)); |
329 if (fnarg->llvmAttrs) | 329 if (fnarg->llvmAttrs) |
330 palist = palist.addAttr(j+1, fnarg->llvmAttrs); | 330 palist = palist.addAttr(j+1, fnarg->llvmAttrs); |
331 } | 331 } |
353 CallOrInvoke* call = gIR->CreateCallOrInvoke(callable, args.begin(), args.end(), varname); | 353 CallOrInvoke* call = gIR->CreateCallOrInvoke(callable, args.begin(), args.end(), varname); |
354 | 354 |
355 // get return value | 355 // get return value |
356 LLValue* retllval = (retinptr) ? args[0] : call->get(); | 356 LLValue* retllval = (retinptr) ? args[0] : call->get(); |
357 | 357 |
358 // if the type of retllval is abstract, refine to concrete | 358 // repaint the type if necessary |
359 if (retllval->getType()->isAbstract()) | 359 if (resulttype) |
360 retllval = DtoBitCast(retllval, getPtrToType(DtoType(resulttype)), "retval"); | 360 { |
361 Type* rbase = resulttype->toBasetype(); | |
362 Type* nextbase = tf->next->toBasetype(); | |
363 if (!rbase->equals(nextbase)) | |
364 { | |
365 Logger::println("repainting return value from '%s' to '%s'", tf->next->toChars(), rbase->toChars()); | |
366 switch(rbase->ty) | |
367 { | |
368 case Tarray: | |
369 retllval = DtoAggrPaint(retllval, DtoType(rbase)); | |
370 break; | |
371 | |
372 case Tclass: | |
373 case Taarray: | |
374 case Tpointer: | |
375 retllval = DtoBitCast(retllval, DtoType(rbase)); | |
376 break; | |
377 | |
378 default: | |
379 assert(0 && "unhandled repainting of return value"); | |
380 } | |
381 if (Logger::enabled()) | |
382 Logger::cout() << "final return value: " << *retllval << '\n'; | |
383 } | |
384 } | |
361 | 385 |
362 // set calling convention and parameter attributes | 386 // set calling convention and parameter attributes |
363 if (dfnval && dfnval->func) | 387 if (dfnval && dfnval->func) |
364 { | 388 { |
365 LLFunction* llfunc = llvm::dyn_cast<LLFunction>(dfnval->val); | 389 LLFunction* llfunc = llvm::dyn_cast<LLFunction>(dfnval->val); |