Mercurial > projects > ldc
diff gen/llvmhelpers.cpp @ 747:46d0755451a4
Added DtoRawVarDeclaration routine to handle special variables in some statements.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 01 Nov 2008 18:25:10 +0100 |
parents | 7261ff0f95ff |
children | 2c730d530c98 |
line wrap: on
line diff
--- a/gen/llvmhelpers.cpp Sat Nov 01 17:56:25 2008 +0100 +++ b/gen/llvmhelpers.cpp Sat Nov 01 18:25:10 2008 +0100 @@ -1320,6 +1320,46 @@ return NULL; } +// does pretty much the same as DtoDeclarationExp, except it doesn't initialize, and only handles var declarations +LLValue* DtoRawVarDeclaration(VarDeclaration* var) +{ + // we don't handle globals with this one + assert(!var->isDataseg()); + + // we don't handle aliases either + assert(!var->aliassym); + + // referenced by nested function? + if (var->nestedref) + { + assert(var->ir.irLocal); + assert(!var->ir.irLocal->value); + + // alloca + var->ir.irLocal->value = DtoAlloca(DtoType(var->type), var->toChars()); + + // store the address into the nested vars array + assert(var->ir.irLocal->nestedIndex >= 0); + LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, var->ir.irLocal->nestedIndex); + assert(isaPointer(var->ir.irLocal->value)); + LLValue* val = DtoBitCast(var->ir.irLocal->value, getVoidPtrType()); + DtoStore(val, gep); + } + // normal local variable + else + { + assert(!var->ir.isSet()); + var->ir.irLocal = new IrLocal(var); + var->ir.irLocal->value = DtoAlloca(DtoType(var->type), var->toChars()); + } + + // add debug info + if (global.params.symdebug) + DtoDwarfLocalVariable(var->ir.irLocal->value, var); + + // return the alloca + return var->ir.irLocal->value; +} /****************************************************************************************/ /*////////////////////////////////////////////////////////////////////////////////////////