Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 747:46d0755451a4

Show
Ignore:
Timestamp:
11/01/08 13:25:10 (2 months ago)
Author:
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
branch:
default
Message:

Added DtoRawVarDeclaration? routine to handle special variables in some statements.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gen/llvmhelpers.cpp

    r719 r747  
    13211321} 
    13221322 
     1323// does pretty much the same as DtoDeclarationExp, except it doesn't initialize, and only handles var declarations 
     1324LLValue* 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} 
    13231363 
    13241364/****************************************************************************************/ 
  • gen/llvmhelpers.h

    r715 r747  
    8484// declaration inside a declarationexp 
    8585DValue* DtoDeclarationExp(Dsymbol* declaration); 
     86LLValue* DtoRawVarDeclaration(VarDeclaration* var); 
    8687 
    8788// initializer helpers 
  • gen/statements.cpp

    r745 r747  
    155155 
    156156    if (match) 
    157         DtoDeclarationExp(match); 
     157        DtoRawVarDeclaration(match); 
    158158 
    159159    DValue* cond_e = condition->toElem(p); 
     
    927927    LLValue* keyvar; 
    928928    if (key) 
    929     { 
    930         DtoDeclarationExp(key); 
    931         keyvar = key->ir.irLocal->value; 
    932     } 
     929        keyvar = DtoRawVarDeclaration(key); 
    933930    else 
    934931        keyvar = DtoAlloca(keytype, "foreachkey"); 
     
    937934    // value 
    938935    Logger::println("value = %s", value->toPrettyChars()); 
    939     DtoDeclarationExp(value); 
     936    DtoRawVarDeclaration(value); 
    940937    const LLType* valtype = DtoType(value->type); 
    941938    LLValue* valvar = NULL; 
     
    11501147 
    11511148    DValue* e = exp->toElem(p); 
    1152  
    1153     // DtoDeclarationExp(wthis); or preferably equivalent without initialization... 
    1154     if (wthis->ir.isSet()) 
    1155     { 
    1156         assert(wthis->nestedref); 
    1157         assert(wthis->ir.irLocal); 
    1158         assert(!wthis->ir.irLocal->value); 
    1159         wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars()); 
    1160  
    1161         // store the address into the nested vars array 
    1162         assert(wthis->ir.irLocal->nestedIndex >= 0); 
    1163         LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, wthis->ir.irLocal->nestedIndex); 
    1164         assert(isaPointer(wthis->ir.irLocal->value)); 
    1165         LLValue* val = DtoBitCast(wthis->ir.irLocal->value, getVoidPtrType()); 
    1166         DtoStore(val, gep); 
    1167     } 
    1168     else 
    1169     { 
    1170         assert(!wthis->nestedref); 
    1171         wthis->ir.irLocal = new IrLocal(wthis); 
    1172         wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars()); 
    1173     } 
    1174  
    1175     DtoStore(e->getRVal(), wthis->ir.irLocal->value); 
     1149    LLValue* mem = DtoRawVarDeclaration(wthis); 
     1150    DtoStore(e->getRVal(), mem); 
    11761151 
    11771152    body->toIR(p); 
Copyright © 2008, LDC Development Team.