Mercurial > projects > ldc
comparison gen/toir.cpp @ 173:db9890b3fb64 trunk
[svn r189] moving IR data back into DMD frontend nodes
author | ChristianK |
---|---|
date | Tue, 06 May 2008 07:56:03 +0200 |
parents | 68a7dd38c03c |
children | c44e6a711885 |
comparison
equal
deleted
inserted
replaced
172:68a7dd38c03c | 173:db9890b3fb64 |
---|---|
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(gIR->irDsymbol[vd].irLocal); | 64 assert(vd->ir.irLocal); |
65 gIR->irDsymbol[vd].irLocal->value = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar; | 65 vd->ir.irLocal->value = p->func()->decl->ir.irFunc->nestedVar; |
66 assert(gIR->irDsymbol[vd].irLocal->value); | 66 assert(vd->ir.irLocal->value); |
67 assert(gIR->irDsymbol[vd].irLocal->nestedIndex >= 0); | 67 assert(vd->ir.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(!gIR->irDsymbol[vd].irLocal); | 75 assert(!vd->ir.irLocal); |
76 gIR->irDsymbol[vd].irLocal = new IrLocal(vd); | 76 vd->ir.irLocal = new IrLocal(vd); |
77 gIR->irDsymbol[vd].irLocal->value = allocainst; | 77 vd->ir.irLocal->value = allocainst; |
78 } | 78 } |
79 | 79 |
80 Logger::cout() << "llvm value for decl: " << *gIR->irDsymbol[vd].irLocal->value << '\n'; | 80 Logger::cout() << "llvm value for decl: " << *vd->ir.irLocal->value << '\n'; |
81 DValue* ie = DtoInitializer(vd->init); | 81 DValue* ie = DtoInitializer(vd->init); |
82 } | 82 } |
83 | 83 |
84 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true); | 84 return new DVarValue(vd, vd->ir.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 (!gIR->irDsymbol[vd].getIrValue()) | 156 /*if (!vd->ir.getIrValue()) |
157 gIR->irDsymbol[vd].getIrValue() = p->func()->decl->irFunc->_arguments; | 157 vd->ir.getIrValue() = p->func()->decl->irFunc->_arguments; |
158 assert(gIR->irDsymbol[vd].getIrValue()); | 158 assert(vd->ir.getIrValue()); |
159 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);*/ | 159 return new DVarValue(vd, vd->ir.getIrValue(), true);*/ |
160 llvm::Value* v = gIR->irDsymbol[p->func()->decl].irFunc->_arguments; | 160 llvm::Value* v = p->func()->decl->ir.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 (!gIR->irDsymbol[vd].getIrValue()) | 168 /*if (!vd->ir.getIrValue()) |
169 gIR->irDsymbol[vd].getIrValue() = p->func()->decl->irFunc->_argptr; | 169 vd->ir.getIrValue() = p->func()->decl->irFunc->_argptr; |
170 assert(gIR->irDsymbol[vd].getIrValue()); | 170 assert(vd->ir.getIrValue()); |
171 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);*/ | 171 return new DVarValue(vd, vd->ir.getIrValue(), true);*/ |
172 llvm::Value* v = gIR->irDsymbol[p->func()->decl].irFunc->_argptr; | 172 llvm::Value* v = p->func()->decl->ir.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(gIR->irDsymbol[tid].getIrValue()); | 189 assert(tid->ir.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 (gIR->irDsymbol[tid].getIrValue()->getType() != getPtrToType(vartype)) | 192 if (tid->ir.getIrValue()->getType() != getPtrToType(vartype)) |
193 m = p->ir->CreateBitCast(gIR->irDsymbol[tid].getIrValue(), vartype, "tmp"); | 193 m = p->ir->CreateBitCast(tid->ir.getIrValue(), vartype, "tmp"); |
194 else | 194 else |
195 m = gIR->irDsymbol[tid].getIrValue(); | 195 m = tid->ir.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(gIR->irDsymbol[cid->cd].irStruct->classInfo); | 203 assert(cid->cd->ir.irStruct->classInfo); |
204 return new DVarValue(vd, gIR->irDsymbol[cid->cd].irStruct->classInfo, true); | 204 return new DVarValue(vd, cid->cd->ir.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->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(gIR->irDsymbol[vd].getIrValue())) { | 214 if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->ir.getIrValue())) { |
215 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true); | 215 return new DVarValue(vd, vd->ir.getIrValue(), true); |
216 } | 216 } |
217 else if (llvm::isa<llvm::Argument>(gIR->irDsymbol[vd].getIrValue())) { | 217 else if (llvm::isa<llvm::Argument>(vd->ir.getIrValue())) { |
218 return new DImValue(type, gIR->irDsymbol[vd].getIrValue()); | 218 return new DImValue(type, vd->ir.getIrValue()); |
219 } | 219 } |
220 else assert(0); | 220 else assert(0); |
221 } | 221 } |
222 else { | 222 else { |
223 // take care of forward references of global variables | 223 // take care of forward references of global variables |
224 if (vd->isDataseg() || (vd->storage_class & STCextern)) { | 224 if (vd->isDataseg() || (vd->storage_class & STCextern)) { |
225 vd->toObjFile(); | 225 vd->toObjFile(); |
226 DtoConstInitGlobal(vd); | 226 DtoConstInitGlobal(vd); |
227 } | 227 } |
228 if (!gIR->irDsymbol[vd].getIrValue() || DtoType(vd->type)->isAbstract()) { | 228 if (!vd->ir.getIrValue() || DtoType(vd->type)->isAbstract()) { |
229 Logger::println("global variable not resolved :/ %s", vd->toChars()); | 229 Logger::println("global variable not resolved :/ %s", vd->toChars()); |
230 Logger::cout() << *DtoType(vd->type) << '\n'; | 230 Logger::cout() << *DtoType(vd->type) << '\n'; |
231 assert(0); | 231 assert(0); |
232 } | 232 } |
233 return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true); | 233 return new DVarValue(vd, vd->ir.getIrValue(), true); |
234 } | 234 } |
235 } | 235 } |
236 else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) | 236 else if (FuncDeclaration* fdecl = var->isFuncDeclaration()) |
237 { | 237 { |
238 Logger::println("FuncDeclaration"); | 238 Logger::println("FuncDeclaration"); |
239 if (fdecl->llvmInternal != LLVMva_arg) {// && fdecl->llvmValue == 0) | 239 if (fdecl->llvmInternal != LLVMva_arg) {// && fdecl->llvmValue == 0) |
240 DtoForceDeclareDsymbol(fdecl); | 240 DtoForceDeclareDsymbol(fdecl); |
241 } | 241 } |
242 return new DFuncValue(fdecl, gIR->irDsymbol[fdecl].irFunc->func); | 242 return new DFuncValue(fdecl, fdecl->ir.irFunc->func); |
243 } | 243 } |
244 else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration()) | 244 else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration()) |
245 { | 245 { |
246 // this seems to be the static initialiser for structs | 246 // this seems to be the static initialiser for structs |
247 Type* sdecltype = DtoDType(sdecl->type); | 247 Type* sdecltype = DtoDType(sdecl->type); |
248 Logger::print("Sym: type=%s\n", sdecltype->toChars()); | 248 Logger::print("Sym: type=%s\n", sdecltype->toChars()); |
249 assert(sdecltype->ty == Tstruct); | 249 assert(sdecltype->ty == Tstruct); |
250 TypeStruct* ts = (TypeStruct*)sdecltype; | 250 TypeStruct* ts = (TypeStruct*)sdecltype; |
251 assert(ts->sym); | 251 assert(ts->sym); |
252 DtoForceConstInitDsymbol(ts->sym); | 252 DtoForceConstInitDsymbol(ts->sym); |
253 assert(gIR->irDsymbol[ts->sym].irStruct->init); | 253 assert(ts->sym->ir.irStruct->init); |
254 return new DVarValue(type, gIR->irDsymbol[ts->sym].irStruct->init, true); | 254 return new DVarValue(type, ts->sym->ir.irStruct->init, true); |
255 } | 255 } |
256 else | 256 else |
257 { | 257 { |
258 assert(0 && "Unimplemented VarExp type"); | 258 assert(0 && "Unimplemented VarExp type"); |
259 } | 259 } |
273 Type* sdecltype = DtoDType(sdecl->type); | 273 Type* sdecltype = DtoDType(sdecl->type); |
274 Logger::print("Sym: type=%s\n", sdecltype->toChars()); | 274 Logger::print("Sym: type=%s\n", sdecltype->toChars()); |
275 assert(sdecltype->ty == Tstruct); | 275 assert(sdecltype->ty == Tstruct); |
276 TypeStruct* ts = (TypeStruct*)sdecltype; | 276 TypeStruct* ts = (TypeStruct*)sdecltype; |
277 DtoForceConstInitDsymbol(ts->sym); | 277 DtoForceConstInitDsymbol(ts->sym); |
278 assert(gIR->irDsymbol[ts->sym].irStruct->constInit); | 278 assert(ts->sym->ir.irStruct->constInit); |
279 return gIR->irDsymbol[ts->sym].irStruct->constInit; | 279 return ts->sym->ir.irStruct->constInit; |
280 } | 280 } |
281 else if (TypeInfoDeclaration* ti = var->isTypeInfoDeclaration()) | 281 else if (TypeInfoDeclaration* ti = var->isTypeInfoDeclaration()) |
282 { | 282 { |
283 DtoForceDeclareDsymbol(ti); | 283 DtoForceDeclareDsymbol(ti); |
284 assert(gIR->irDsymbol[ti].getIrValue()); | 284 assert(ti->ir.getIrValue()); |
285 const llvm::Type* vartype = DtoType(type); | 285 const llvm::Type* vartype = DtoType(type); |
286 llvm::Constant* m = isaConstant(gIR->irDsymbol[ti].getIrValue()); | 286 llvm::Constant* m = isaConstant(ti->ir.getIrValue()); |
287 assert(m); | 287 assert(m); |
288 if (gIR->irDsymbol[ti].getIrValue()->getType() != getPtrToType(vartype)) | 288 if (ti->ir.getIrValue()->getType() != getPtrToType(vartype)) |
289 m = llvm::ConstantExpr::getBitCast(m, vartype); | 289 m = llvm::ConstantExpr::getBitCast(m, vartype); |
290 return m; | 290 return m; |
291 } | 291 } |
292 assert(0 && "Unsupported const VarExp kind"); | 292 assert(0 && "Unsupported const VarExp kind"); |
293 return NULL; | 293 return NULL; |
1081 DtoAnnotation(argexp->toChars()); | 1081 DtoAnnotation(argexp->toChars()); |
1082 DtoVariadicArgument(argexp, DtoGEPi(mem,0,k,"tmp")); | 1082 DtoVariadicArgument(argexp, DtoGEPi(mem,0,k,"tmp")); |
1083 } | 1083 } |
1084 | 1084 |
1085 // build type info array | 1085 // build type info array |
1086 assert(gIR->irDsymbol[Type::typeinfo].irStruct->constInit); | 1086 assert(Type::typeinfo->ir.irStruct->constInit); |
1087 const llvm::Type* typeinfotype = DtoType(Type::typeinfo->type); | 1087 const llvm::Type* typeinfotype = DtoType(Type::typeinfo->type); |
1088 const llvm::ArrayType* typeinfoarraytype = llvm::ArrayType::get(typeinfotype,vtype->getNumElements()); | 1088 const llvm::ArrayType* typeinfoarraytype = llvm::ArrayType::get(typeinfotype,vtype->getNumElements()); |
1089 | 1089 |
1090 llvm::Value* typeinfomem = new llvm::AllocaInst(typeinfoarraytype,"_arguments_storage",p->topallocapoint()); | 1090 llvm::Value* typeinfomem = new llvm::AllocaInst(typeinfoarraytype,"_arguments_storage",p->topallocapoint()); |
1091 Logger::cout() << "_arguments storage: " << *typeinfomem << '\n'; | 1091 Logger::cout() << "_arguments storage: " << *typeinfomem << '\n'; |
1092 for (int i=begin,k=0; i<arguments->dim; i++,k++) | 1092 for (int i=begin,k=0; i<arguments->dim; i++,k++) |
1093 { | 1093 { |
1094 Expression* argexp = (Expression*)arguments->data[i]; | 1094 Expression* argexp = (Expression*)arguments->data[i]; |
1095 TypeInfoDeclaration* tidecl = argexp->type->getTypeInfoDeclaration(); | 1095 TypeInfoDeclaration* tidecl = argexp->type->getTypeInfoDeclaration(); |
1096 DtoForceDeclareDsymbol(tidecl); | 1096 DtoForceDeclareDsymbol(tidecl); |
1097 assert(gIR->irDsymbol[tidecl].getIrValue()); | 1097 assert(tidecl->ir.getIrValue()); |
1098 vtypeinfos.push_back(gIR->irDsymbol[tidecl].getIrValue()); | 1098 vtypeinfos.push_back(tidecl->ir.getIrValue()); |
1099 llvm::Value* v = p->ir->CreateBitCast(vtypeinfos[k], typeinfotype, "tmp"); | 1099 llvm::Value* v = p->ir->CreateBitCast(vtypeinfos[k], typeinfotype, "tmp"); |
1100 p->ir->CreateStore(v, DtoGEPi(typeinfomem,0,k,"tmp")); | 1100 p->ir->CreateStore(v, DtoGEPi(typeinfomem,0,k,"tmp")); |
1101 } | 1101 } |
1102 | 1102 |
1103 // put data in d-array | 1103 // put data in d-array |
1235 if (VarDeclaration* vd = var->isVarDeclaration()) | 1235 if (VarDeclaration* vd = var->isVarDeclaration()) |
1236 { | 1236 { |
1237 Logger::println("VarDeclaration"); | 1237 Logger::println("VarDeclaration"); |
1238 | 1238 |
1239 // handle forward reference | 1239 // handle forward reference |
1240 if (!gIR->irDsymbol[vd].declared && vd->isDataseg()) { | 1240 if (!vd->ir.declared && vd->isDataseg()) { |
1241 vd->toObjFile(); // TODO | 1241 vd->toObjFile(); // TODO |
1242 } | 1242 } |
1243 | 1243 |
1244 assert(gIR->irDsymbol[vd].getIrValue()); | 1244 assert(vd->ir.getIrValue()); |
1245 Type* t = DtoDType(type); | 1245 Type* t = DtoDType(type); |
1246 Type* tnext = DtoDType(t->next); | 1246 Type* tnext = DtoDType(t->next); |
1247 Type* vdtype = DtoDType(vd->type); | 1247 Type* vdtype = DtoDType(vd->type); |
1248 | 1248 |
1249 llvm::Value* llvalue = vd->nestedref ? DtoNestedVariable(vd) : gIR->irDsymbol[vd].getIrValue(); | 1249 llvm::Value* llvalue = vd->nestedref ? DtoNestedVariable(vd) : vd->ir.getIrValue(); |
1250 llvm::Value* varmem = 0; | 1250 llvm::Value* varmem = 0; |
1251 | 1251 |
1252 if (vdtype->ty == Tstruct && !(t->ty == Tpointer && t->next == vdtype)) { | 1252 if (vdtype->ty == Tstruct && !(t->ty == Tpointer && t->next == vdtype)) { |
1253 Logger::println("struct"); | 1253 Logger::println("struct"); |
1254 TypeStruct* vdt = (TypeStruct*)vdtype; | 1254 TypeStruct* vdt = (TypeStruct*)vdtype; |
1319 Logger::println("is func"); | 1319 Logger::println("is func"); |
1320 //Logger::println("FuncDeclaration"); | 1320 //Logger::println("FuncDeclaration"); |
1321 FuncDeclaration* fd = fv->func; | 1321 FuncDeclaration* fd = fv->func; |
1322 assert(fd); | 1322 assert(fd); |
1323 DtoForceDeclareDsymbol(fd); | 1323 DtoForceDeclareDsymbol(fd); |
1324 return new DFuncValue(fd, gIR->irDsymbol[fd].irFunc->func); | 1324 return new DFuncValue(fd, fd->ir.irFunc->func); |
1325 } | 1325 } |
1326 else if (DImValue* im = v->isIm()) { | 1326 else if (DImValue* im = v->isIm()) { |
1327 Logger::println("is immediate"); | 1327 Logger::println("is immediate"); |
1328 return v; | 1328 return v; |
1329 } | 1329 } |
1425 //unsigned cc = (unsigned)-1; | 1425 //unsigned cc = (unsigned)-1; |
1426 | 1426 |
1427 // super call | 1427 // super call |
1428 if (e1->op == TOKsuper) { | 1428 if (e1->op == TOKsuper) { |
1429 DtoForceDeclareDsymbol(fdecl); | 1429 DtoForceDeclareDsymbol(fdecl); |
1430 funcval = gIR->irDsymbol[fdecl].irFunc->func; | 1430 funcval = fdecl->ir.irFunc->func; |
1431 assert(funcval); | 1431 assert(funcval); |
1432 } | 1432 } |
1433 // normal virtual call | 1433 // normal virtual call |
1434 else if (fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual())) { | 1434 else if (fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual())) { |
1435 assert(fdecl->vtblIndex > 0); | 1435 assert(fdecl->vtblIndex > 0); |
1446 //cc = DtoCallingConv(fdecl->linkage); | 1446 //cc = DtoCallingConv(fdecl->linkage); |
1447 } | 1447 } |
1448 // static call | 1448 // static call |
1449 else { | 1449 else { |
1450 DtoForceDeclareDsymbol(fdecl); | 1450 DtoForceDeclareDsymbol(fdecl); |
1451 funcval = gIR->irDsymbol[fdecl].irFunc->func; | 1451 funcval = fdecl->ir.irFunc->func; |
1452 assert(funcval); | 1452 assert(funcval); |
1453 //assert(funcval->getType() == DtoType(fdecl->type)); | 1453 //assert(funcval->getType() == DtoType(fdecl->type)); |
1454 } | 1454 } |
1455 return new DFuncValue(fdecl, funcval, vthis2); | 1455 return new DFuncValue(fdecl, funcval, vthis2); |
1456 } | 1456 } |
1469 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars()); | 1469 Logger::print("ThisExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1470 LOG_SCOPE; | 1470 LOG_SCOPE; |
1471 | 1471 |
1472 if (VarDeclaration* vd = var->isVarDeclaration()) { | 1472 if (VarDeclaration* vd = var->isVarDeclaration()) { |
1473 llvm::Value* v; | 1473 llvm::Value* v; |
1474 v = gIR->irDsymbol[p->func()->decl].irFunc->thisVar; | 1474 v = p->func()->decl->ir.irFunc->thisVar; |
1475 if (llvm::isa<llvm::AllocaInst>(v)) | 1475 if (llvm::isa<llvm::AllocaInst>(v)) |
1476 v = new llvm::LoadInst(v, "tmp", p->scopebb()); | 1476 v = new llvm::LoadInst(v, "tmp", p->scopebb()); |
1477 return new DThisValue(vd, v); | 1477 return new DThisValue(vd, v); |
1478 } | 1478 } |
1479 | 1479 |
1936 if (ts->isZeroInit()) { | 1936 if (ts->isZeroInit()) { |
1937 DtoStructZeroInit(emem); | 1937 DtoStructZeroInit(emem); |
1938 } | 1938 } |
1939 else { | 1939 else { |
1940 assert(ts->sym); | 1940 assert(ts->sym); |
1941 DtoStructCopy(emem,gIR->irDsymbol[ts->sym].irStruct->init); | 1941 DtoStructCopy(emem,ts->sym->ir.irStruct->init); |
1942 } | 1942 } |
1943 } | 1943 } |
1944 | 1944 |
1945 return new DImValue(type, emem, inplace); | 1945 return new DImValue(type, emem, inplace); |
1946 } | 1946 } |
2221 DValue* u = e1->toElem(p); | 2221 DValue* u = e1->toElem(p); |
2222 llvm::Value* uval; | 2222 llvm::Value* uval; |
2223 if (DFuncValue* f = u->isFunc()) { | 2223 if (DFuncValue* f = u->isFunc()) { |
2224 //assert(f->vthis); | 2224 //assert(f->vthis); |
2225 //uval = f->vthis; | 2225 //uval = f->vthis; |
2226 llvm::Value* nestvar = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar; | 2226 llvm::Value* nestvar = p->func()->decl->ir.irFunc->nestedVar; |
2227 if (nestvar) | 2227 if (nestvar) |
2228 uval = nestvar; | 2228 uval = nestvar; |
2229 else | 2229 else |
2230 uval = llvm::ConstantPointerNull::get(int8ptrty); | 2230 uval = llvm::ConstantPointerNull::get(int8ptrty); |
2231 } | 2231 } |
2261 else if (func->toParent()->isInterfaceDeclaration()) | 2261 else if (func->toParent()->isInterfaceDeclaration()) |
2262 assert(0 && "TODO delegate to interface method"); | 2262 assert(0 && "TODO delegate to interface method"); |
2263 else | 2263 else |
2264 { | 2264 { |
2265 DtoForceDeclareDsymbol(func); | 2265 DtoForceDeclareDsymbol(func); |
2266 castfptr = gIR->irDsymbol[func].irFunc->func; | 2266 castfptr = func->ir.irFunc->func; |
2267 } | 2267 } |
2268 | 2268 |
2269 castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0)); | 2269 castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0)); |
2270 DtoStore(castfptr, fptr); | 2270 DtoStore(castfptr, fptr); |
2271 | 2271 |
2519 temp = true; | 2519 temp = true; |
2520 } | 2520 } |
2521 | 2521 |
2522 llvm::Value* context = DtoGEPi(lval,0,0,"tmp",p->scopebb()); | 2522 llvm::Value* context = DtoGEPi(lval,0,0,"tmp",p->scopebb()); |
2523 const llvm::PointerType* pty = isaPointer(context->getType()->getContainedType(0)); | 2523 const llvm::PointerType* pty = isaPointer(context->getType()->getContainedType(0)); |
2524 llvm::Value* llvmNested = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar; | 2524 llvm::Value* llvmNested = p->func()->decl->ir.irFunc->nestedVar; |
2525 if (llvmNested == NULL) { | 2525 if (llvmNested == NULL) { |
2526 llvm::Value* nullcontext = llvm::ConstantPointerNull::get(pty); | 2526 llvm::Value* nullcontext = llvm::ConstantPointerNull::get(pty); |
2527 p->ir->CreateStore(nullcontext, context); | 2527 p->ir->CreateStore(nullcontext, context); |
2528 } | 2528 } |
2529 else { | 2529 else { |
2531 p->ir->CreateStore(nestedcontext, context); | 2531 p->ir->CreateStore(nestedcontext, context); |
2532 } | 2532 } |
2533 | 2533 |
2534 llvm::Value* fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb()); | 2534 llvm::Value* fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb()); |
2535 | 2535 |
2536 assert(gIR->irDsymbol[fd].irFunc->func); | 2536 assert(fd->ir.irFunc->func); |
2537 llvm::Value* castfptr = new llvm::BitCastInst(gIR->irDsymbol[fd].irFunc->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb()); | 2537 llvm::Value* castfptr = new llvm::BitCastInst(fd->ir.irFunc->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb()); |
2538 new llvm::StoreInst(castfptr, fptr, p->scopebb()); | 2538 new llvm::StoreInst(castfptr, fptr, p->scopebb()); |
2539 | 2539 |
2540 if (temp) | 2540 if (temp) |
2541 return new DVarValue(type, lval, true); | 2541 return new DVarValue(type, lval, true); |
2542 else | 2542 else |
2661 | 2661 |
2662 // num elements in literal | 2662 // num elements in literal |
2663 unsigned n = elements->dim; | 2663 unsigned n = elements->dim; |
2664 | 2664 |
2665 // unions might have different types for each literal | 2665 // unions might have different types for each literal |
2666 if (gIR->irDsymbol[sd].irStruct->hasUnions) { | 2666 if (sd->ir.irStruct->hasUnions) { |
2667 // build the type of the literal | 2667 // build the type of the literal |
2668 std::vector<const llvm::Type*> tys; | 2668 std::vector<const llvm::Type*> tys; |
2669 for (unsigned i=0; i<n; ++i) { | 2669 for (unsigned i=0; i<n; ++i) { |
2670 Expression* vx = (Expression*)elements->data[i]; | 2670 Expression* vx = (Expression*)elements->data[i]; |
2671 if (!vx) continue; | 2671 if (!vx) continue; |