comparison 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
comparison
equal deleted inserted replaced
746:693d681c846c 747:46d0755451a4
1318 assert(0); 1318 assert(0);
1319 } 1319 }
1320 return NULL; 1320 return NULL;
1321 } 1321 }
1322 1322
1323 // does pretty much the same as DtoDeclarationExp, except it doesn't initialize, and only handles var declarations
1324 LLValue* DtoRawVarDeclaration(VarDeclaration* var)
1325 {
1326 // we don't handle globals with this one
1327 assert(!var->isDataseg());
1328
1329 // we don't handle aliases either
1330 assert(!var->aliassym);
1331
1332 // referenced by nested function?
1333 if (var->nestedref)
1334 {
1335 assert(var->ir.irLocal);
1336 assert(!var->ir.irLocal->value);
1337
1338 // alloca
1339 var->ir.irLocal->value = DtoAlloca(DtoType(var->type), var->toChars());
1340
1341 // store the address into the nested vars array
1342 assert(var->ir.irLocal->nestedIndex >= 0);
1343 LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, var->ir.irLocal->nestedIndex);
1344 assert(isaPointer(var->ir.irLocal->value));
1345 LLValue* val = DtoBitCast(var->ir.irLocal->value, getVoidPtrType());
1346 DtoStore(val, gep);
1347 }
1348 // normal local variable
1349 else
1350 {
1351 assert(!var->ir.isSet());
1352 var->ir.irLocal = new IrLocal(var);
1353 var->ir.irLocal->value = DtoAlloca(DtoType(var->type), var->toChars());
1354 }
1355
1356 // add debug info
1357 if (global.params.symdebug)
1358 DtoDwarfLocalVariable(var->ir.irLocal->value, var);
1359
1360 // return the alloca
1361 return var->ir.irLocal->value;
1362 }
1323 1363
1324 /****************************************************************************************/ 1364 /****************************************************************************************/
1325 /*//////////////////////////////////////////////////////////////////////////////////////// 1365 /*////////////////////////////////////////////////////////////////////////////////////////
1326 // INITIALIZER HELPERS 1366 // INITIALIZER HELPERS
1327 ////////////////////////////////////////////////////////////////////////////////////////*/ 1367 ////////////////////////////////////////////////////////////////////////////////////////*/