diff gen/tollvm.cpp @ 156:ccd07d9f2ce9 trunk

[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
author ChristianK
date Thu, 01 May 2008 13:05:53 +0200
parents 7f92f477ff53
children 5c17f81fc1c1
line wrap: on
line diff
--- a/gen/tollvm.cpp	Tue Apr 29 21:33:50 2008 +0200
+++ b/gen/tollvm.cpp	Thu May 01 13:05:53 2008 +0200
@@ -116,7 +116,7 @@
         TypeStruct* ts = (TypeStruct*)t;
         assert(ts->sym);
         DtoResolveDsymbol(ts->sym);
-        return ts->sym->irStruct->recty.get();//t->llvmType->get();
+        return gIR->irDsymbol[ts->sym].irStruct->recty.get();//t->llvmType->get();
     }
 
     case Tclass:    {
@@ -139,7 +139,7 @@
         TypeClass* tc = (TypeClass*)t;
         assert(tc->sym);
         DtoResolveDsymbol(tc->sym);
-        return getPtrToType(tc->sym->irStruct->recty.get());//t->llvmType->get());
+        return getPtrToType(gIR->irDsymbol[tc->sym].irStruct->recty.get());//t->llvmType->get());
     }
 
     // functions
@@ -561,8 +561,8 @@
             TypeStruct* ts = (TypeStruct*)t;
             assert(ts);
             assert(ts->sym);
-            assert(ts->sym->irStruct->constInit);
-            _init = ts->sym->irStruct->constInit;
+            assert(gIR->irDsymbol[ts->sym].irStruct->constInit);
+            _init = gIR->irDsymbol[ts->sym].irStruct->constInit;
         }
         else if (t->ty == Tclass)
         {
@@ -724,7 +724,7 @@
     assert(p->isFuncDeclaration() || p->isClassDeclaration());
     if (FuncDeclaration* fd = p->isFuncDeclaration())
     {
-        llvm::Value* v = gIR->irFunc[fd]->nestedVar;
+        llvm::Value* v = gIR->irDsymbol[fd].irFunc->nestedVar;
         assert(v);
         return v->getType();
     }
@@ -754,9 +754,9 @@
 
         if (fd->toParent2() == func)
         {
-            if (!gIR->irFunc[func]->nestedVar)
+            if (!gIR->irDsymbol[func].irFunc->nestedVar)
                 return NULL;
-            return DtoBitCast(v, gIR->irFunc[func]->nestedVar->getType());
+            return DtoBitCast(v, gIR->irDsymbol[func].irFunc->nestedVar->getType());
         }
 
         v = DtoBitCast(v, get_next_frame_ptr_type(fd));
@@ -770,7 +770,7 @@
         else if (ClassDeclaration* cd = fd->toParent2()->isClassDeclaration())
         {
             size_t idx = 2;
-            //idx += cd->irStruct->interfaceVec.size();
+            //idx += gIR->irDsymbol[cd].irStruct->interfaceVec.size();
             v = DtoGEPi(v,0,idx,"tmp");
             v = DtoLoad(v);
         }
@@ -807,10 +807,10 @@
 
     // in the right scope already
     if (func == irfunc->decl)
-        return gIR->irFunc[irfunc->decl]->nestedVar;
+        return gIR->irDsymbol[irfunc->decl].irFunc->nestedVar;
 
     // use the 'this' pointer
-    llvm::Value* ptr = gIR->irFunc[irfunc->decl]->thisVar;
+    llvm::Value* ptr = gIR->irDsymbol[irfunc->decl].irFunc->thisVar;
     assert(ptr);
 
     // return the fully resolved frame pointer
@@ -878,10 +878,10 @@
     assert(ptr && "nested var, but no context");
 
     // we must cast here to be sure. nested classes just have a void*
-    ptr = DtoBitCast(ptr, gIR->irFunc[func]->nestedVar->getType());
+    ptr = DtoBitCast(ptr, gIR->irDsymbol[func].irFunc->nestedVar->getType());
 
     // index nested var and load (if necessary)
-    llvm::Value* v = DtoGEPi(ptr, 0, vd->irLocal->nestedIndex, "tmp");
+    llvm::Value* v = DtoGEPi(ptr, 0, gIR->irDsymbol[vd].irLocal->nestedIndex, "tmp");
     // references must be loaded, for normal variables this IS already the variable storage!!!
     if (vd->isParameter() && (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type)))
         v = DtoLoad(v);
@@ -964,9 +964,9 @@
             llvm::Value* tmp = rhs->getRVal();
             FuncDeclaration* fdecl = gIR->func()->decl;
             // respecify the this param
-            if (!llvm::isa<llvm::AllocaInst>(gIR->irFunc[fdecl]->thisVar))
-                gIR->irFunc[fdecl]->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint());
-            DtoStore(tmp, gIR->irFunc[fdecl]->thisVar);
+            if (!llvm::isa<llvm::AllocaInst>(gIR->irDsymbol[fdecl].irFunc->thisVar))
+                gIR->irDsymbol[fdecl].irFunc->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint());
+            DtoStore(tmp, gIR->irDsymbol[fdecl].irFunc->thisVar);
         }
         // regular class ref -> class ref assignment
         else {
@@ -1572,8 +1572,8 @@
 
 void DtoConstInitGlobal(VarDeclaration* vd)
 {
-    if (vd->llvmInitialized) return;
-    vd->llvmInitialized = gIR->dmodule;
+    if (gIR->irDsymbol[vd].initialized) return;
+    gIR->irDsymbol[vd].initialized = gIR->dmodule;
 
     Logger::println("* DtoConstInitGlobal(%s)", vd->toChars());
     LOG_SCOPE;
@@ -1605,8 +1605,8 @@
             llvm::GlobalVariable* gv = llvm::cast<llvm::GlobalVariable>(_init);
             assert(t->ty == Tstruct);
             TypeStruct* ts = (TypeStruct*)t;
-            assert(ts->sym->irStruct->constInit);
-            _init = ts->sym->irStruct->constInit;
+            assert(gIR->irDsymbol[ts->sym].irStruct->constInit);
+            _init = gIR->irDsymbol[ts->sym].irStruct->constInit;
         }
         // array single value init
         else if (isaArray(_type))
@@ -1626,11 +1626,11 @@
 
     if (_init && _init->getType() != _type)
         _type = _init->getType();
-    llvm::cast<llvm::OpaqueType>(vd->irGlobal->type.get())->refineAbstractTypeTo(_type);
-    _type = vd->irGlobal->type.get();
+    llvm::cast<llvm::OpaqueType>(gIR->irDsymbol[vd].irGlobal->type.get())->refineAbstractTypeTo(_type);
+    _type = gIR->irDsymbol[vd].irGlobal->type.get();
     assert(!_type->isAbstract());
 
-    llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(vd->irGlobal->value);
+    llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(gIR->irDsymbol[vd].irGlobal->value);
     if (!(vd->storage_class & STCextern) && (vd->getModule() == gIR->dmodule || istempl))
     {
         gvar->setInitializer(_init);
@@ -1728,7 +1728,7 @@
 
 void DtoForceDeclareDsymbol(Dsymbol* dsym)
 {
-    if (dsym->llvmDeclared) return;
+    if (gIR->irDsymbol[dsym].declared) return;
     Logger::println("DtoForceDeclareDsymbol(%s)", dsym->toPrettyChars());
     LOG_SCOPE;
     DtoResolveDsymbol(dsym);
@@ -1742,7 +1742,7 @@
 
 void DtoForceConstInitDsymbol(Dsymbol* dsym)
 {
-    if (dsym->llvmInitialized) return;
+    if (gIR->irDsymbol[dsym].initialized) return;
     Logger::println("DtoForceConstInitDsymbol(%s)", dsym->toPrettyChars());
     LOG_SCOPE;
     DtoResolveDsymbol(dsym);
@@ -1757,7 +1757,7 @@
 
 void DtoForceDefineDsymbol(Dsymbol* dsym)
 {
-    if (dsym->llvmDefined) return;
+    if (gIR->irDsymbol[dsym].defined) return;
     Logger::println("DtoForceDefineDsymbol(%s)", dsym->toPrettyChars());
     LOG_SCOPE;
     DtoResolveDsymbol(dsym);