Mercurial > projects > ldc
comparison gen/toir.cpp @ 121:9c79b61fb638 trunk
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
Unit tests are now implemented.
author | lindquist |
---|---|
date | Tue, 27 Nov 2007 03:09:36 +0100 |
parents | 5ce8ab11e75a |
children | 36ab367572df |
comparison
equal
deleted
inserted
replaced
120:5ce8ab11e75a | 121:9c79b61fb638 |
---|---|
213 // this seems to be the static initialiser for structs | 213 // this seems to be the static initialiser for structs |
214 Type* sdecltype = DtoDType(sdecl->type); | 214 Type* sdecltype = DtoDType(sdecl->type); |
215 Logger::print("Sym: type=%s\n", sdecltype->toChars()); | 215 Logger::print("Sym: type=%s\n", sdecltype->toChars()); |
216 assert(sdecltype->ty == Tstruct); | 216 assert(sdecltype->ty == Tstruct); |
217 TypeStruct* ts = (TypeStruct*)sdecltype; | 217 TypeStruct* ts = (TypeStruct*)sdecltype; |
218 assert(ts->llvmInit); | 218 assert(ts->sym); |
219 return new DVarValue(type, ts->llvmInit, true); | 219 assert(ts->sym->llvmInit); |
220 return new DVarValue(type, ts->sym->llvmInit, true); | |
220 } | 221 } |
221 else | 222 else |
222 { | 223 { |
223 assert(0 && "Unimplemented VarExp type"); | 224 assert(0 && "Unimplemented VarExp type"); |
224 } | 225 } |
238 Type* sdecltype = DtoDType(sdecl->type); | 239 Type* sdecltype = DtoDType(sdecl->type); |
239 Logger::print("Sym: type=%s\n", sdecltype->toChars()); | 240 Logger::print("Sym: type=%s\n", sdecltype->toChars()); |
240 assert(sdecltype->ty == Tstruct); | 241 assert(sdecltype->ty == Tstruct); |
241 TypeStruct* ts = (TypeStruct*)sdecltype; | 242 TypeStruct* ts = (TypeStruct*)sdecltype; |
242 DtoForceConstInitDsymbol(ts->sym); | 243 DtoForceConstInitDsymbol(ts->sym); |
243 assert(ts->sym->llvmInitZ); | 244 assert(ts->sym->llvmConstInit); |
244 return ts->sym->llvmInitZ; | 245 return ts->sym->llvmConstInit; |
245 } | 246 } |
246 assert(0 && "Only supported const VarExp is of a SymbolDeclaration"); | 247 assert(0 && "Only supported const VarExp is of a SymbolDeclaration"); |
247 return NULL; | 248 return NULL; |
248 } | 249 } |
249 | 250 |
1002 llvm::Value* mem = new llvm::AllocaInst(vtype,"_argptr_storage",p->topallocapoint()); | 1003 llvm::Value* mem = new llvm::AllocaInst(vtype,"_argptr_storage",p->topallocapoint()); |
1003 for (unsigned i=0; i<vtype->getNumElements(); ++i) | 1004 for (unsigned i=0; i<vtype->getNumElements(); ++i) |
1004 p->ir->CreateStore(vvalues[i], DtoGEPi(mem,0,i,"tmp")); | 1005 p->ir->CreateStore(vvalues[i], DtoGEPi(mem,0,i,"tmp")); |
1005 | 1006 |
1006 //llvm::Constant* typeinfoparam = llvm::ConstantPointerNull::get(isaPointer(llfnty->getParamType(j))); | 1007 //llvm::Constant* typeinfoparam = llvm::ConstantPointerNull::get(isaPointer(llfnty->getParamType(j))); |
1007 assert(Type::typeinfo->llvmInitZ); | 1008 assert(Type::typeinfo->llvmConstInit); |
1008 const llvm::Type* typeinfotype = llvm::PointerType::get(Type::typeinfo->llvmInitZ->getType()); | 1009 const llvm::Type* typeinfotype = llvm::PointerType::get(Type::typeinfo->llvmConstInit->getType()); |
1009 Logger::cout() << "typeinfo ptr type: " << *typeinfotype << '\n'; | 1010 Logger::cout() << "typeinfo ptr type: " << *typeinfotype << '\n'; |
1010 const llvm::ArrayType* typeinfoarraytype = llvm::ArrayType::get(typeinfotype,vtype->getNumElements()); | 1011 const llvm::ArrayType* typeinfoarraytype = llvm::ArrayType::get(typeinfotype,vtype->getNumElements()); |
1011 llvm::Value* typeinfomem = new llvm::AllocaInst(typeinfoarraytype,"_arguments_storage",p->topallocapoint()); | 1012 llvm::Value* typeinfomem = new llvm::AllocaInst(typeinfoarraytype,"_arguments_storage",p->topallocapoint()); |
1012 for (unsigned i=0; i<vtype->getNumElements(); ++i) { | 1013 for (unsigned i=0; i<vtype->getNumElements(); ++i) { |
1013 llvm::Value* v = p->ir->CreateBitCast(vtypeinfos[i], typeinfotype, "tmp"); | 1014 llvm::Value* v = p->ir->CreateBitCast(vtypeinfos[i], typeinfotype, "tmp"); |
1828 TypeStruct* ts = (TypeStruct*)ntype; | 1829 TypeStruct* ts = (TypeStruct*)ntype; |
1829 if (ts->isZeroInit()) { | 1830 if (ts->isZeroInit()) { |
1830 DtoStructZeroInit(emem); | 1831 DtoStructZeroInit(emem); |
1831 } | 1832 } |
1832 else { | 1833 else { |
1833 DtoStructCopy(emem,ts->llvmInit); | 1834 assert(ts->sym); |
1835 DtoStructCopy(emem,ts->sym->llvmInit); | |
1834 } | 1836 } |
1835 } | 1837 } |
1836 | 1838 |
1837 return new DImValue(type, emem, inplace); | 1839 return new DImValue(type, emem, inplace); |
1838 } | 1840 } |