comparison gen/toir.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 1856c62af24b
comparison
equal deleted inserted replaced
155:7f92f477ff53 156:ccd07d9f2ce9
59 Logger::println("vdtype = %s", vd->type->toChars()); 59 Logger::println("vdtype = %s", vd->type->toChars());
60 60
61 // referenced by nested delegate? 61 // referenced by nested delegate?
62 if (vd->nestedref) { 62 if (vd->nestedref) {
63 Logger::println("has nestedref set"); 63 Logger::println("has nestedref set");
64 assert(vd->irLocal); 64 assert(gIR->irDsymbol[vd].irLocal);
65 vd->irLocal->value = gIR->irFunc[p->func()->decl]->nestedVar; 65 gIR->irDsymbol[vd].irLocal->value = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar;
66 assert(vd->irLocal->value); 66 assert(gIR->irDsymbol[vd].irLocal->value);
67 assert(vd->irLocal->nestedIndex >= 0); 67 assert(gIR->irDsymbol[vd].irLocal->nestedIndex >= 0);
68 } 68 }
69 // normal stack variable 69 // normal stack variable
70 else { 70 else {
71 // allocate storage on the stack 71 // allocate storage on the stack
72 const llvm::Type* lltype = DtoType(vd->type); 72 const llvm::Type* lltype = DtoType(vd->type);
73 llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint()); 73 llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint());
74 //allocainst->setAlignment(vd->type->alignsize()); // TODO 74 //allocainst->setAlignment(vd->type->alignsize()); // TODO
75 assert(!vd->irLocal); 75 assert(!gIR->irDsymbol[vd].irLocal);
76 vd->irLocal = new IrLocal(vd); 76 gIR->irDsymbol[vd].irLocal = new IrLocal(vd);
77 vd->irLocal->value = allocainst; 77 gIR->irDsymbol[vd].irLocal->value = allocainst;
78 } 78 }
79 79
80 Logger::cout() << "llvm value for decl: " << *vd->irLocal->value << '\n'; 80 Logger::cout() << "llvm value for decl: " << *gIR->irDsymbol[vd].irLocal->value << '\n';
81 DValue* ie = DtoInitializer(vd->init); 81 DValue* ie = DtoInitializer(vd->init);
82 } 82 }
83 83
84 return new DVarValue(vd, vd->getIrValue(), true); 84 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);
85 } 85 }
86 // struct declaration 86 // struct declaration
87 else if (StructDeclaration* s = declaration->isStructDeclaration()) 87 else if (StructDeclaration* s = declaration->isStructDeclaration())
88 { 88 {
89 Logger::println("StructDeclaration"); 89 Logger::println("StructDeclaration");
151 151
152 // _arguments 152 // _arguments
153 if (vd->ident == Id::_arguments) 153 if (vd->ident == Id::_arguments)
154 { 154 {
155 Logger::println("Id::_arguments"); 155 Logger::println("Id::_arguments");
156 /*if (!vd->getIrValue()) 156 /*if (!gIR->irDsymbol[vd].getIrValue())
157 vd->getIrValue() = p->func()->decl->irFunc->_arguments; 157 gIR->irDsymbol[vd].getIrValue() = p->func()->decl->irFunc->_arguments;
158 assert(vd->getIrValue()); 158 assert(gIR->irDsymbol[vd].getIrValue());
159 return new DVarValue(vd, vd->getIrValue(), true);*/ 159 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);*/
160 llvm::Value* v = gIR->irFunc[p->func()->decl]->_arguments; 160 llvm::Value* v = gIR->irDsymbol[p->func()->decl].irFunc->_arguments;
161 assert(v); 161 assert(v);
162 return new DVarValue(vd, v, true); 162 return new DVarValue(vd, v, true);
163 } 163 }
164 // _argptr 164 // _argptr
165 else if (vd->ident == Id::_argptr) 165 else if (vd->ident == Id::_argptr)
166 { 166 {
167 Logger::println("Id::_argptr"); 167 Logger::println("Id::_argptr");
168 /*if (!vd->getIrValue()) 168 /*if (!gIR->irDsymbol[vd].getIrValue())
169 vd->getIrValue() = p->func()->decl->irFunc->_argptr; 169 gIR->irDsymbol[vd].getIrValue() = p->func()->decl->irFunc->_argptr;
170 assert(vd->getIrValue()); 170 assert(gIR->irDsymbol[vd].getIrValue());
171 return new DVarValue(vd, vd->getIrValue(), true);*/ 171 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);*/
172 llvm::Value* v = gIR->irFunc[p->func()->decl]->_argptr; 172 llvm::Value* v = gIR->irDsymbol[p->func()->decl].irFunc->_argptr;
173 assert(v); 173 assert(v);
174 return new DVarValue(vd, v, true); 174 return new DVarValue(vd, v, true);
175 } 175 }
176 // _dollar 176 // _dollar
177 else if (vd->ident == Id::dollar) 177 else if (vd->ident == Id::dollar)
184 // typeinfo 184 // typeinfo
185 else if (TypeInfoDeclaration* tid = vd->isTypeInfoDeclaration()) 185 else if (TypeInfoDeclaration* tid = vd->isTypeInfoDeclaration())
186 { 186 {
187 Logger::println("TypeInfoDeclaration"); 187 Logger::println("TypeInfoDeclaration");
188 DtoForceDeclareDsymbol(tid); 188 DtoForceDeclareDsymbol(tid);
189 assert(tid->getIrValue()); 189 assert(gIR->irDsymbol[tid].getIrValue());
190 const llvm::Type* vartype = DtoType(type); 190 const llvm::Type* vartype = DtoType(type);
191 llvm::Value* m; 191 llvm::Value* m;
192 if (tid->getIrValue()->getType() != getPtrToType(vartype)) 192 if (gIR->irDsymbol[tid].getIrValue()->getType() != getPtrToType(vartype))
193 m = p->ir->CreateBitCast(tid->getIrValue(), vartype, "tmp"); 193 m = p->ir->CreateBitCast(gIR->irDsymbol[tid].getIrValue(), vartype, "tmp");
194 else 194 else
195 m = tid->getIrValue(); 195 m = gIR->irDsymbol[tid].getIrValue();
196 return new DVarValue(vd, m, true); 196 return new DVarValue(vd, m, true);
197 } 197 }
198 // classinfo 198 // classinfo
199 else if (ClassInfoDeclaration* cid = vd->isClassInfoDeclaration()) 199 else if (ClassInfoDeclaration* cid = vd->isClassInfoDeclaration())
200 { 200 {
201 Logger::println("ClassInfoDeclaration: %s", cid->cd->toChars()); 201 Logger::println("ClassInfoDeclaration: %s", cid->cd->toChars());
202 DtoDeclareClassInfo(cid->cd); 202 DtoDeclareClassInfo(cid->cd);
203 assert(cid->cd->irStruct->classInfo); 203 assert(gIR->irDsymbol[cid->cd].irStruct->classInfo);
204 return new DVarValue(vd, cid->cd->irStruct->classInfo, true); 204 return new DVarValue(vd, gIR->irDsymbol[cid->cd].irStruct->classInfo, true);
205 } 205 }
206 // nested variable 206 // nested variable
207 else if (vd->nestedref) { 207 else if (vd->nestedref) {
208 Logger::println("nested variable"); 208 Logger::println("nested variable");
209 return new DVarValue(vd, DtoNestedVariable(vd), true); 209 return new DVarValue(vd, DtoNestedVariable(vd), true);
210 } 210 }
211 // function parameter 211 // function parameter
212 else if (vd->isParameter()) { 212 else if (vd->isParameter()) {
213 Logger::println("function param"); 213 Logger::println("function param");
214 if (!vd->getIrValue()) { 214 if (!gIR->irDsymbol[vd].getIrValue()) {
215 // TODO: determine this properly 215 // TODO: determine this properly
216 // this happens when the DMD frontend generates by pointer wrappers for struct opEquals(S) and opCmp(S) 216 // this happens when the DMD frontend generates by pointer wrappers for struct opEquals(S) and opCmp(S)
217 vd->getIrValue() = &p->func()->func->getArgumentList().back(); 217 gIR->irDsymbol[vd].getIrValue() = &p->func()->func->getArgumentList().back();
218 } 218 }
219 if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->getIrValue())) { 219 if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(gIR->irDsymbol[vd].getIrValue())) {
220 return new DVarValue(vd, vd->getIrValue(), true); 220 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);
221 } 221 }
222 else if (llvm::isa<llvm::Argument>(vd->getIrValue())) { 222 else if (llvm::isa<llvm::Argument>(gIR->irDsymbol[vd].getIrValue())) {
223 return new DImValue(type, vd->getIrValue()); 223 return new DImValue(type, gIR->irDsymbol[vd].getIrValue());
224 } 224 }
225 else assert(0); 225 else assert(0);
226 } 226 }
227 else { 227 else {
228 // take care of forward references of global variables 228 // take care of forward references of global variables
229 if (vd->isDataseg() || (vd->storage_class & STCextern)) { 229 if (vd->isDataseg() || (vd->storage_class & STCextern)) {
230 vd->toObjFile(); 230 vd->toObjFile();
231 DtoConstInitGlobal(vd); 231 DtoConstInitGlobal(vd);
232 } 232 }
233 if (!vd->getIrValue() || vd->getIrValue()->getType()->isAbstract()) { 233 if (!gIR->irDsymbol[vd].getIrValue() || gIR->irDsymbol[vd].getIrValue()->getType()->isAbstract()) {
234 Logger::println("global variable not resolved :/ %s", vd->toChars()); 234 Logger::println("global variable not resolved :/ %s", vd->toChars());
235 assert(0); 235 assert(0);
236 } 236 }
237 return new DVarValue(vd, vd->getIrValue(), true); 237 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);
238 } 238 }
239 } 239 }
240 else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) 240 else if (FuncDeclaration* fdecl = var->isFuncDeclaration())
241 { 241 {
242 Logger::println("FuncDeclaration"); 242 Logger::println("FuncDeclaration");
243 if (fdecl->llvmInternal != LLVMva_arg) {// && fdecl->llvmValue == 0) 243 if (fdecl->llvmInternal != LLVMva_arg) {// && fdecl->llvmValue == 0)
244 DtoForceDeclareDsymbol(fdecl); 244 DtoForceDeclareDsymbol(fdecl);
245 } 245 }
246 return new DFuncValue(fdecl, gIR->irFunc[fdecl]->func); 246 return new DFuncValue(fdecl, gIR->irDsymbol[fdecl].irFunc->func);
247 } 247 }
248 else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration()) 248 else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration())
249 { 249 {
250 // this seems to be the static initialiser for structs 250 // this seems to be the static initialiser for structs
251 Type* sdecltype = DtoDType(sdecl->type); 251 Type* sdecltype = DtoDType(sdecl->type);
252 Logger::print("Sym: type=%s\n", sdecltype->toChars()); 252 Logger::print("Sym: type=%s\n", sdecltype->toChars());
253 assert(sdecltype->ty == Tstruct); 253 assert(sdecltype->ty == Tstruct);
254 TypeStruct* ts = (TypeStruct*)sdecltype; 254 TypeStruct* ts = (TypeStruct*)sdecltype;
255 assert(ts->sym); 255 assert(ts->sym);
256 assert(ts->sym->irStruct->init); 256 assert(gIR->irDsymbol[ts->sym].irStruct->init);
257 return new DVarValue(type, ts->sym->irStruct->init, true); 257 return new DVarValue(type, gIR->irDsymbol[ts->sym].irStruct->init, true);
258 } 258 }
259 else 259 else
260 { 260 {
261 assert(0 && "Unimplemented VarExp type"); 261 assert(0 && "Unimplemented VarExp type");
262 } 262 }
276 Type* sdecltype = DtoDType(sdecl->type); 276 Type* sdecltype = DtoDType(sdecl->type);
277 Logger::print("Sym: type=%s\n", sdecltype->toChars()); 277 Logger::print("Sym: type=%s\n", sdecltype->toChars());
278 assert(sdecltype->ty == Tstruct); 278 assert(sdecltype->ty == Tstruct);
279 TypeStruct* ts = (TypeStruct*)sdecltype; 279 TypeStruct* ts = (TypeStruct*)sdecltype;
280 DtoForceConstInitDsymbol(ts->sym); 280 DtoForceConstInitDsymbol(ts->sym);
281 assert(ts->sym->irStruct->constInit); 281 assert(gIR->irDsymbol[ts->sym].irStruct->constInit);
282 return ts->sym->irStruct->constInit; 282 return gIR->irDsymbol[ts->sym].irStruct->constInit;
283 } 283 }
284 else if (TypeInfoDeclaration* ti = var->isTypeInfoDeclaration()) 284 else if (TypeInfoDeclaration* ti = var->isTypeInfoDeclaration())
285 { 285 {
286 DtoForceDeclareDsymbol(ti); 286 DtoForceDeclareDsymbol(ti);
287 assert(ti->getIrValue()); 287 assert(gIR->irDsymbol[ti].getIrValue());
288 const llvm::Type* vartype = DtoType(type); 288 const llvm::Type* vartype = DtoType(type);
289 llvm::Constant* m = isaConstant(ti->getIrValue()); 289 llvm::Constant* m = isaConstant(gIR->irDsymbol[ti].getIrValue());
290 assert(m); 290 assert(m);
291 if (ti->getIrValue()->getType() != getPtrToType(vartype)) 291 if (gIR->irDsymbol[ti].getIrValue()->getType() != getPtrToType(vartype))
292 m = llvm::ConstantExpr::getBitCast(m, vartype); 292 m = llvm::ConstantExpr::getBitCast(m, vartype);
293 return m; 293 return m;
294 } 294 }
295 assert(0 && "Unsupported const VarExp kind"); 295 assert(0 && "Unsupported const VarExp kind");
296 return NULL; 296 return NULL;
1077 DtoAnnotation(argexp->toChars()); 1077 DtoAnnotation(argexp->toChars());
1078 DtoVariadicArgument(argexp, DtoGEPi(mem,0,k,"tmp")); 1078 DtoVariadicArgument(argexp, DtoGEPi(mem,0,k,"tmp"));
1079 } 1079 }
1080 1080
1081 // build type info array 1081 // build type info array
1082 assert(Type::typeinfo->irStruct->constInit); 1082 assert(gIR->irDsymbol[Type::typeinfo].irStruct->constInit);
1083 const llvm::Type* typeinfotype = DtoType(Type::typeinfo->type); 1083 const llvm::Type* typeinfotype = DtoType(Type::typeinfo->type);
1084 const llvm::ArrayType* typeinfoarraytype = llvm::ArrayType::get(typeinfotype,vtype->getNumElements()); 1084 const llvm::ArrayType* typeinfoarraytype = llvm::ArrayType::get(typeinfotype,vtype->getNumElements());
1085 1085
1086 llvm::Value* typeinfomem = new llvm::AllocaInst(typeinfoarraytype,"_arguments_storage",p->topallocapoint()); 1086 llvm::Value* typeinfomem = new llvm::AllocaInst(typeinfoarraytype,"_arguments_storage",p->topallocapoint());
1087 Logger::cout() << "_arguments storage: " << *typeinfomem << '\n'; 1087 Logger::cout() << "_arguments storage: " << *typeinfomem << '\n';
1088 for (int i=begin,k=0; i<arguments->dim; i++,k++) 1088 for (int i=begin,k=0; i<arguments->dim; i++,k++)
1089 { 1089 {
1090 Expression* argexp = (Expression*)arguments->data[i]; 1090 Expression* argexp = (Expression*)arguments->data[i];
1091 TypeInfoDeclaration* tidecl = argexp->type->getTypeInfoDeclaration(); 1091 TypeInfoDeclaration* tidecl = argexp->type->getTypeInfoDeclaration();
1092 DtoForceDeclareDsymbol(tidecl); 1092 DtoForceDeclareDsymbol(tidecl);
1093 assert(tidecl->getIrValue()); 1093 assert(gIR->irDsymbol[tidecl].getIrValue());
1094 vtypeinfos.push_back(tidecl->getIrValue()); 1094 vtypeinfos.push_back(gIR->irDsymbol[tidecl].getIrValue());
1095 llvm::Value* v = p->ir->CreateBitCast(vtypeinfos[k], typeinfotype, "tmp"); 1095 llvm::Value* v = p->ir->CreateBitCast(vtypeinfos[k], typeinfotype, "tmp");
1096 p->ir->CreateStore(v, DtoGEPi(typeinfomem,0,k,"tmp")); 1096 p->ir->CreateStore(v, DtoGEPi(typeinfomem,0,k,"tmp"));
1097 } 1097 }
1098 1098
1099 // put data in d-array 1099 // put data in d-array
1231 if (VarDeclaration* vd = var->isVarDeclaration()) 1231 if (VarDeclaration* vd = var->isVarDeclaration())
1232 { 1232 {
1233 Logger::println("VarDeclaration"); 1233 Logger::println("VarDeclaration");
1234 1234
1235 // handle forward reference 1235 // handle forward reference
1236 if (!vd->llvmDeclared && vd->isDataseg()) { 1236 if (!gIR->irDsymbol[vd].declared && vd->isDataseg()) {
1237 vd->toObjFile(); // TODO 1237 vd->toObjFile(); // TODO
1238 } 1238 }
1239 1239
1240 assert(vd->getIrValue()); 1240 assert(gIR->irDsymbol[vd].getIrValue());
1241 Type* t = DtoDType(type); 1241 Type* t = DtoDType(type);
1242 Type* tnext = DtoDType(t->next); 1242 Type* tnext = DtoDType(t->next);
1243 Type* vdtype = DtoDType(vd->type); 1243 Type* vdtype = DtoDType(vd->type);
1244 1244
1245 llvm::Value* llvalue = vd->nestedref ? DtoNestedVariable(vd) : vd->getIrValue(); 1245 llvm::Value* llvalue = vd->nestedref ? DtoNestedVariable(vd) : gIR->irDsymbol[vd].getIrValue();
1246 llvm::Value* varmem = 0; 1246 llvm::Value* varmem = 0;
1247 1247
1248 if (vdtype->ty == Tstruct && !(t->ty == Tpointer && t->next == vdtype)) { 1248 if (vdtype->ty == Tstruct && !(t->ty == Tpointer && t->next == vdtype)) {
1249 Logger::println("struct"); 1249 Logger::println("struct");
1250 TypeStruct* vdt = (TypeStruct*)vdtype; 1250 TypeStruct* vdt = (TypeStruct*)vdtype;
1315 Logger::println("is func"); 1315 Logger::println("is func");
1316 //Logger::println("FuncDeclaration"); 1316 //Logger::println("FuncDeclaration");
1317 FuncDeclaration* fd = fv->func; 1317 FuncDeclaration* fd = fv->func;
1318 assert(fd); 1318 assert(fd);
1319 DtoForceDeclareDsymbol(fd); 1319 DtoForceDeclareDsymbol(fd);
1320 return new DFuncValue(fd, gIR->irFunc[fd]->func); 1320 return new DFuncValue(fd, gIR->irDsymbol[fd].irFunc->func);
1321 } 1321 }
1322 else if (DImValue* im = v->isIm()) { 1322 else if (DImValue* im = v->isIm()) {
1323 Logger::println("is immediate"); 1323 Logger::println("is immediate");
1324 return v; 1324 return v;
1325 } 1325 }
1420 //unsigned cc = (unsigned)-1; 1420 //unsigned cc = (unsigned)-1;
1421 1421
1422 // super call 1422 // super call
1423 if (e1->op == TOKsuper) { 1423 if (e1->op == TOKsuper) {
1424 DtoForceDeclareDsymbol(fdecl); 1424 DtoForceDeclareDsymbol(fdecl);
1425 funcval = gIR->irFunc[fdecl]->func; 1425 funcval = gIR->irDsymbol[fdecl].irFunc->func;
1426 assert(funcval); 1426 assert(funcval);
1427 } 1427 }
1428 // normal virtual call 1428 // normal virtual call
1429 else if (fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual())) { 1429 else if (fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual())) {
1430 assert(fdecl->vtblIndex > 0); 1430 assert(fdecl->vtblIndex > 0);
1441 //cc = DtoCallingConv(fdecl->linkage); 1441 //cc = DtoCallingConv(fdecl->linkage);
1442 } 1442 }
1443 // static call 1443 // static call
1444 else { 1444 else {
1445 DtoForceDeclareDsymbol(fdecl); 1445 DtoForceDeclareDsymbol(fdecl);
1446 funcval = gIR->irFunc[fdecl]->func; 1446 funcval = gIR->irDsymbol[fdecl].irFunc->func;
1447 assert(funcval); 1447 assert(funcval);
1448 //assert(funcval->getType() == DtoType(fdecl->type)); 1448 //assert(funcval->getType() == DtoType(fdecl->type));
1449 } 1449 }
1450 return new DFuncValue(fdecl, funcval, vthis2); 1450 return new DFuncValue(fdecl, funcval, vthis2);
1451 } 1451 }
1464 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars()); 1464 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars());
1465 LOG_SCOPE; 1465 LOG_SCOPE;
1466 1466
1467 if (VarDeclaration* vd = var->isVarDeclaration()) { 1467 if (VarDeclaration* vd = var->isVarDeclaration()) {
1468 llvm::Value* v; 1468 llvm::Value* v;
1469 v = gIR->irFunc[p->func()->decl]->thisVar; 1469 v = gIR->irDsymbol[p->func()->decl].irFunc->thisVar;
1470 if (llvm::isa<llvm::AllocaInst>(v)) 1470 if (llvm::isa<llvm::AllocaInst>(v))
1471 v = new llvm::LoadInst(v, "tmp", p->scopebb()); 1471 v = new llvm::LoadInst(v, "tmp", p->scopebb());
1472 return new DThisValue(vd, v); 1472 return new DThisValue(vd, v);
1473 } 1473 }
1474 1474
1930 if (ts->isZeroInit()) { 1930 if (ts->isZeroInit()) {
1931 DtoStructZeroInit(emem); 1931 DtoStructZeroInit(emem);
1932 } 1932 }
1933 else { 1933 else {
1934 assert(ts->sym); 1934 assert(ts->sym);
1935 DtoStructCopy(emem,ts->sym->irStruct->init); 1935 DtoStructCopy(emem,gIR->irDsymbol[ts->sym].irStruct->init);
1936 } 1936 }
1937 } 1937 }
1938 1938
1939 return new DImValue(type, emem, inplace); 1939 return new DImValue(type, emem, inplace);
1940 } 1940 }
2214 DValue* u = e1->toElem(p); 2214 DValue* u = e1->toElem(p);
2215 llvm::Value* uval; 2215 llvm::Value* uval;
2216 if (DFuncValue* f = u->isFunc()) { 2216 if (DFuncValue* f = u->isFunc()) {
2217 //assert(f->vthis); 2217 //assert(f->vthis);
2218 //uval = f->vthis; 2218 //uval = f->vthis;
2219 llvm::Value* nestvar = gIR->irFunc[p->func()->decl]->nestedVar; 2219 llvm::Value* nestvar = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar;
2220 if (nestvar) 2220 if (nestvar)
2221 uval = nestvar; 2221 uval = nestvar;
2222 else 2222 else
2223 uval = llvm::ConstantPointerNull::get(int8ptrty); 2223 uval = llvm::ConstantPointerNull::get(int8ptrty);
2224 } 2224 }
2254 else if (func->toParent()->isInterfaceDeclaration()) 2254 else if (func->toParent()->isInterfaceDeclaration())
2255 assert(0 && "TODO delegate to interface method"); 2255 assert(0 && "TODO delegate to interface method");
2256 else 2256 else
2257 { 2257 {
2258 DtoForceDeclareDsymbol(func); 2258 DtoForceDeclareDsymbol(func);
2259 castfptr = gIR->irFunc[func]->func; 2259 castfptr = gIR->irDsymbol[func].irFunc->func;
2260 } 2260 }
2261 2261
2262 castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0)); 2262 castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0));
2263 DtoStore(castfptr, fptr); 2263 DtoStore(castfptr, fptr);
2264 2264
2488 temp = true; 2488 temp = true;
2489 } 2489 }
2490 2490
2491 llvm::Value* context = DtoGEPi(lval,0,0,"tmp",p->scopebb()); 2491 llvm::Value* context = DtoGEPi(lval,0,0,"tmp",p->scopebb());
2492 const llvm::PointerType* pty = isaPointer(context->getType()->getContainedType(0)); 2492 const llvm::PointerType* pty = isaPointer(context->getType()->getContainedType(0));
2493 llvm::Value* llvmNested = gIR->irFunc[p->func()->decl]->nestedVar; 2493 llvm::Value* llvmNested = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar;
2494 if (llvmNested == NULL) { 2494 if (llvmNested == NULL) {
2495 llvm::Value* nullcontext = llvm::ConstantPointerNull::get(pty); 2495 llvm::Value* nullcontext = llvm::ConstantPointerNull::get(pty);
2496 p->ir->CreateStore(nullcontext, context); 2496 p->ir->CreateStore(nullcontext, context);
2497 } 2497 }
2498 else { 2498 else {
2500 p->ir->CreateStore(nestedcontext, context); 2500 p->ir->CreateStore(nestedcontext, context);
2501 } 2501 }
2502 2502
2503 llvm::Value* fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb()); 2503 llvm::Value* fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb());
2504 2504
2505 assert(gIR->irFunc[fd]->func); 2505 assert(gIR->irDsymbol[fd].irFunc->func);
2506 llvm::Value* castfptr = new llvm::BitCastInst(gIR->irFunc[fd]->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb()); 2506 llvm::Value* castfptr = new llvm::BitCastInst(gIR->irDsymbol[fd].irFunc->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb());
2507 new llvm::StoreInst(castfptr, fptr, p->scopebb()); 2507 new llvm::StoreInst(castfptr, fptr, p->scopebb());
2508 2508
2509 if (temp) 2509 if (temp)
2510 return new DVarValue(type, lval, true); 2510 return new DVarValue(type, lval, true);
2511 else 2511 else
2630 2630
2631 // num elements in literal 2631 // num elements in literal
2632 unsigned n = elements->dim; 2632 unsigned n = elements->dim;
2633 2633
2634 // unions might have different types for each literal 2634 // unions might have different types for each literal
2635 if (sd->irStruct->hasUnions) { 2635 if (gIR->irDsymbol[sd].irStruct->hasUnions) {
2636 // build the type of the literal 2636 // build the type of the literal
2637 std::vector<const llvm::Type*> tys; 2637 std::vector<const llvm::Type*> tys;
2638 for (unsigned i=0; i<n; ++i) { 2638 for (unsigned i=0; i<n; ++i) {
2639 Expression* vx = (Expression*)elements->data[i]; 2639 Expression* vx = (Expression*)elements->data[i];
2640 if (!vx) continue; 2640 if (!vx) continue;