Mercurial > projects > ldc
comparison gen/statements.cpp @ 1024:9167d492cbc2
Abstracted more (most) ABI details out of the normal codegen.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 03 Mar 2009 02:51:21 +0100 |
parents | 8c73ff5f69e0 |
children | 45af482e3832 |
comparison
equal
deleted
inserted
replaced
1023:ca191c141cec | 1024:9167d492cbc2 |
---|---|
61 // we are returning through a pointer argument | 61 // we are returning through a pointer argument |
62 if (p->topfunc()->getReturnType() == LLType::VoidTy) | 62 if (p->topfunc()->getReturnType() == LLType::VoidTy) |
63 { | 63 { |
64 // sanity check | 64 // sanity check |
65 IrFunction* f = p->func(); | 65 IrFunction* f = p->func(); |
66 assert(f->type->retInPtr); | |
67 assert(f->decl->ir.irFunc->retArg); | 66 assert(f->decl->ir.irFunc->retArg); |
68 | 67 |
69 // emit dbg line | 68 // emit dbg line |
70 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); | 69 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); |
71 | 70 |
92 DValue* e = exp->toElem(p); | 91 DValue* e = exp->toElem(p); |
93 LLValue* v = e->getRVal(); | 92 LLValue* v = e->getRVal(); |
94 delete e; | 93 delete e; |
95 | 94 |
96 // do abi specific transformations on the return value | 95 // do abi specific transformations on the return value |
97 v = gABI->putRet(p->func()->type, v); | 96 v = p->func()->type->fty->putRet(exp->type, v); |
98 | 97 |
99 if (Logger::enabled()) | 98 if (Logger::enabled()) |
100 Logger::cout() << "return value is '" <<*v << "'\n"; | 99 Logger::cout() << "return value is '" <<*v << "'\n"; |
101 | 100 |
102 // can happen for classes and void main | 101 // can happen for classes and void main |
109 // if we're not in main, just bitcast | 108 // if we're not in main, just bitcast |
110 if (p->topfunc() == p->mainFunc) | 109 if (p->topfunc() == p->mainFunc) |
111 v = llvm::Constant::getNullValue(p->mainFunc->getReturnType()); | 110 v = llvm::Constant::getNullValue(p->mainFunc->getReturnType()); |
112 else | 111 else |
113 v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp"); | 112 v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp"); |
114 | 113 |
115 if (Logger::enabled()) | 114 if (Logger::enabled()) |
116 Logger::cout() << "return value after cast: " << *v << '\n'; | 115 Logger::cout() << "return value after cast: " << *v << '\n'; |
117 } | 116 } |
118 | 117 |
119 DtoEnclosingHandlers(enclosinghandler, NULL); | 118 DtoEnclosingHandlers(enclosinghandler, NULL); |