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

Changeset 1149:5ebe8224988b

Show
Ignore:
Timestamp:
03/27/09 18:17:04 (3 years ago)
Author:
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
branch:
default
Message:

Fixed problems introduced by previous commits that prevented Tango from compiling.

Files:

Legend:

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

    r1148 r1149  
    146146    cd->ir.irStruct = irstruct; 
    147147 
     148    // create the type 
     149    const LLType* t = LLArrayType::get(getVoidPtrType(), cd->vtbl.dim); 
     150    assert(!ts->ir.type); 
     151    ts->ir.type = new LLPATypeHolder(getPtrToType(t)); 
     152 
     153    // ... and ClassInfo 
     154    std::string varname("_D"); 
     155    varname.append(cd->mangle()); 
     156    varname.append("11__InterfaceZ"); 
     157 
     158    // create global 
     159    irstruct->classInfo = new llvm::GlobalVariable(irstruct->classInfoOpaque.get(), false, DtoLinkage(cd), NULL, varname, gIR->module); 
     160 
    148161    // handle base interfaces 
    149162    if (cd->baseclasses.dim) 
     
    168181        } 
    169182    } 
    170  
    171     // create the type 
    172     const LLType* t = LLArrayType::get(getVoidPtrType(), cd->vtbl.dim); 
    173     assert(!ts->ir.type); 
    174     ts->ir.type = new LLPATypeHolder(getPtrToType(t)); 
    175183 
    176184    // request declaration 
     
    239247 
    240248    // ... and initZ 
    241     std::string initname("_D"); 
    242     initname.append(cd->mangle()); 
    243     initname.append("6__initZ"); 
    244     irstruct->init = new llvm::GlobalVariable(irstruct->initOpaque.get(), true, _linkage, NULL, initname, gIR->module); 
     249    varname = "_D"; 
     250    varname.append(cd->mangle()); 
     251    varname.append("6__initZ"); 
     252    irstruct->init = new llvm::GlobalVariable(irstruct->initOpaque.get(), true, _linkage, NULL, varname, gIR->module); 
     253 
     254    // ... and ClassInfo 
     255    varname = "_D"; 
     256    varname.append(cd->mangle()); 
     257    varname.append("7__ClassZ"); 
     258 
     259    // create global 
     260    irstruct->classInfo = new llvm::GlobalVariable(irstruct->classInfoOpaque.get(), false, _linkage, NULL, varname, gIR->module); 
    245261 
    246262    // push state 
     
    778794    // refine __initZ global type to the one of the initializer 
    779795    llvm::cast<llvm::OpaqueType>(irstruct->initOpaque.get())->refineAbstractTypeTo(irstruct->constInit->getType()); 
     796 
     797    // build initializers for static member variables 
     798    size_t n = irstruct->staticVars.size(); 
     799    for (size_t i = 0; i < n; ++i) 
     800    { 
     801        DtoConstInitGlobal(irstruct->staticVars[i]); 
     802    } 
     803    // This is all we use it for. Clear the memory! 
     804    irstruct->staticVars.clear(); 
    780805 
    781806//     if (Logger::enabled()) 
     
    13341359    ClassDeclaration* cinfo = ClassDeclaration::classinfo; 
    13351360    DtoResolveClass(cinfo); 
    1336  
    1337     // do the mangle 
    1338     std::string gname("_D"); 
    1339     gname.append(cd->mangle()); 
    1340     if (!cd->isInterfaceDeclaration()) 
    1341         gname.append("7__ClassZ"); 
    1342     else 
    1343         gname.append("11__InterfaceZ"); 
    1344  
    1345     // create global 
    1346     irstruct->classInfo = new llvm::GlobalVariable(irstruct->classInfoOpaque.get(), false, DtoLinkage(cd), NULL, gname, gIR->module); 
    13471361} 
    13481362 
  • gen/declarations.cpp

    r1148 r1149  
    8484        return; 
    8585    } 
     86 
     87    if (AggregateDeclaration* ad = isMember()) 
     88        ad->codegen(p); 
    8689 
    8790    // global variable or magic 
     
    136139            gIR->usedArray.push_back(DtoBitCast(gvar, getVoidPtrType())); 
    137140 
    138         DtoConstInitGlobal(this); 
     141        // don't initialize static struct members yet, they might be of the struct type 
     142        // which doesn't have a static initializer yet. 
     143        if (AggregateDeclaration* ad = isMember()) 
     144            ad->ir.irStruct->staticVars.push_back(this); 
     145        else 
     146            DtoConstInitGlobal(this); 
    139147    } 
    140148    else 
  • gen/functions.cpp

    r1148 r1149  
    302302        Logger::println("Ignoring unittest %s", fdecl->toPrettyChars()); 
    303303        return; // ignore declaration completely 
    304     } 
    305  
    306     // is imported and we don't have access? 
    307     if (fdecl->getModule() != gIR->dmodule) 
    308     { 
    309         if (fdecl->prot() == PROTprivate) 
    310         { 
    311             Logger::println("Ignoring private imported function %s", fdecl->toPrettyChars()); 
    312             return; 
    313         } 
    314304    } 
    315305 
  • gen/main.cpp

    r1147 r1149  
    55 
    66#include "gen/llvm.h" 
     7#include "llvm/LinkAllVMCore.h" 
    78#include "llvm/Linker.h" 
     9#include "llvm/System/Signals.h" 
    810#include "llvm/Target/SubtargetFeature.h" 
    911#include "llvm/Target/TargetMachine.h" 
    1012#include "llvm/Target/TargetMachineRegistry.h" 
    11 #include "llvm/LinkAllVMCore.h" 
    1213 
    1314#include <stdio.h> 
     
    118119int main(int argc, char** argv) 
    119120{ 
     121    // stack trace on signals 
     122    llvm::sys::PrintStackTraceOnErrorSignal(); 
     123 
    120124    Array files; 
    121125    char *p, *ext; 
  • gen/structs.cpp

    r1148 r1149  
    9898 
    9999    // force constant initialization of the symbol 
    100     si->ad->codegen(Type::sir);; 
    101  
    102     // get formal type 
    103     const llvm::StructType* structtype = isaStruct(ts->ir.type->get()); 
    104  
    105 #if 0 
    106     // log it 
    107     if (Logger::enabled()) 
    108         Logger::cout() << "llvm struct type: " << *structtype << '\n'; 
    109 #endif 
     100    si->ad->codegen(Type::sir); 
    110101 
    111102    // sanity check 
     
    242233 
    243234    // there might still be padding after the last one, make sure that is defaulted/zeroed as well 
    244     size_t structsize = getTypePaddedSize(structtype)
     235    size_t structsize = si->ad->structsize
    245236 
    246237    // if there is space before the next explicit initializer 
     
    646637    llvm::cast<llvm::OpaqueType>(irstruct->initOpaque.get())->refineAbstractTypeTo(irstruct->constInit->getType()); 
    647638 
     639    // build initializers for static member variables 
     640    size_t n = irstruct->staticVars.size(); 
     641    for (size_t i = 0; i < n; ++i) 
     642    { 
     643        DtoConstInitGlobal(irstruct->staticVars[i]); 
     644    } 
     645    // This is all we use it for. Clear the memory! 
     646    irstruct->staticVars.clear();  
     647 
    648648    gIR->structs.pop_back(); 
    649649 
  • gen/tocall.cpp

    r1117 r1149  
    327327                ctxarg = gIR->ir->CreateExtractValue(fnval->getRVal(), 0, ".ptr"); 
    328328            } 
    329             assert(ctxarg->getType() == argiter->get()); 
     329            ctxarg = DtoBitCast(ctxarg, argiter->get()); 
    330330            ++argiter; 
    331331            args.push_back(ctxarg); 
  • gen/toir.cpp

    r1148 r1149  
    970970        if (VarDeclaration* vd = vexp->var->isVarDeclaration()) 
    971971        { 
     972            vd->codegen(Type::sir); 
    972973            LLConstant* llc = llvm::dyn_cast<LLConstant>(vd->ir.getIrValue()); 
    973974            assert(llc); 
  • ir/irstruct.h

    r946 r1149  
    151151    // composite type debug description 
    152152    llvm::DICompositeType diCompositeType; 
     153 
     154    std::vector<VarDeclaration*> staticVars; 
    153155}; 
    154156 
Copyright © 2008, LDC Development Team.