Mercurial > projects > ldc
comparison gen/statements.cpp @ 1042:45af482e3832
Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 04 Mar 2009 17:24:25 +0100 |
parents | 9167d492cbc2 |
children | 6bb04dbee21f |
comparison
equal
deleted
inserted
replaced
1041:9dca7182aa75 | 1042:45af482e3832 |
---|---|
66 assert(f->decl->ir.irFunc->retArg); | 66 assert(f->decl->ir.irFunc->retArg); |
67 | 67 |
68 // emit dbg line | 68 // emit dbg line |
69 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); | 69 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); |
70 | 70 |
71 // FIXME: is there ever a case where a sret return needs to be rewritten for the ABI? | |
72 | |
71 // get return pointer | 73 // get return pointer |
72 DValue* rvar = new DVarValue(f->type->next, f->decl->ir.irFunc->retArg); | 74 DValue* rvar = new DVarValue(f->type->next, f->decl->ir.irFunc->retArg); |
73 DValue* e = exp->toElem(p); | 75 DValue* e = exp->toElem(p); |
74 // store return value | 76 // store return value |
75 DtoAssign(loc, rvar, e); | 77 DtoAssign(loc, rvar, e); |
86 } | 88 } |
87 // the return type is not void, so this is a normal "register" return | 89 // the return type is not void, so this is a normal "register" return |
88 else | 90 else |
89 { | 91 { |
90 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); | 92 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); |
91 DValue* e = exp->toElem(p); | |
92 LLValue* v = e->getRVal(); | |
93 delete e; | |
94 | 93 |
95 // do abi specific transformations on the return value | 94 // do abi specific transformations on the return value |
96 v = p->func()->type->fty->putRet(exp->type, v); | 95 LLValue* v = p->func()->type->fty->putRet(exp->type, exp->toElem(p)); |
97 | 96 |
98 if (Logger::enabled()) | 97 if (Logger::enabled()) |
99 Logger::cout() << "return value is '" <<*v << "'\n"; | 98 Logger::cout() << "return value is '" <<*v << "'\n"; |
100 | 99 |
101 // can happen for classes and void main | 100 // can happen for classes and void main |