comparison gen/structs.cpp @ 217:0806379a5eca trunk

[svn r233] Added: -oq command line option for writing fully qualified object names. Added: started support for x86 80bit floating point. Changed: aggregates passed by value now use the llvm 'byval' parameter attribute, also lays ground work for using other attributes. Changed: eliminated a lot more std::vectorS, these showed up pretty much at the top when profiling! Changed: performed other misc. cleanups. Changed: halt expression now call the new llvm trap intrinsic instead of an assert(0). Changed: dstress suite now passes -O0 by default, this only eliminates unreferenced globals, which speeds up linking quite a bit.
author lindquist
date Thu, 05 Jun 2008 06:38:36 +0200
parents 7816aafeea3c
children a95056b3c996
comparison
equal deleted inserted replaced
216:3d022aa016ae 217:0806379a5eca
103 return si->ad->ir.irStruct->dunion->getConst(inits); 103 return si->ad->ir.irStruct->dunion->getConst(inits);
104 } 104 }
105 105
106 ////////////////////////////////////////////////////////////////////////////////////////// 106 //////////////////////////////////////////////////////////////////////////////////////////
107 107
108 LLValue* DtoIndexStruct(LLValue* ptr, StructDeclaration* sd, Type* t, unsigned os, std::vector<unsigned>& idxs) 108 LLValue* DtoIndexStruct(LLValue* ptr, StructDeclaration* sd, Type* t, unsigned os, DStructIndexVector& idxs)
109 { 109 {
110 Logger::println("checking for offset %u type %s:", os, t->toChars()); 110 Logger::println("checking for offset %u type %s:", os, t->toChars());
111 LOG_SCOPE; 111 LOG_SCOPE;
112 112
113 if (idxs.empty()) 113 if (idxs.empty())
125 Type* vdtype = DtoDType(vd->type); 125 Type* vdtype = DtoDType(vd->type);
126 //Logger::println("found %u type %s", vd->offset, vdtype->toChars()); 126 //Logger::println("found %u type %s", vd->offset, vdtype->toChars());
127 assert(vd->ir.irField->index >= 0); 127 assert(vd->ir.irField->index >= 0);
128 if (os == vd->offset && vdtype == t) { 128 if (os == vd->offset && vdtype == t) {
129 idxs.push_back(vd->ir.irField->index); 129 idxs.push_back(vd->ir.irField->index);
130 ptr = DtoGEP(ptr, idxs, "tmp"); 130 ptr = DtoGEPi(ptr, idxs, "tmp");
131 if (ptr->getType() != llt) 131 if (ptr->getType() != llt)
132 ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp"); 132 ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp");
133 if (vd->ir.irField->indexOffset) 133 if (vd->ir.irField->indexOffset)
134 ptr = llvm::GetElementPtrInst::Create(ptr, DtoConstUint(vd->ir.irField->indexOffset), "tmp", gIR->scopebb()); 134 ptr = llvm::GetElementPtrInst::Create(ptr, DtoConstUint(vd->ir.irField->indexOffset), "tmp", gIR->scopebb());
135 return ptr; 135 return ptr;
138 TypeStruct* ts = (TypeStruct*)vdtype; 138 TypeStruct* ts = (TypeStruct*)vdtype;
139 StructDeclaration* ssd = ts->sym; 139 StructDeclaration* ssd = ts->sym;
140 idxs.push_back(vd->ir.irField->index); 140 idxs.push_back(vd->ir.irField->index);
141 if (vd->ir.irField->indexOffset) { 141 if (vd->ir.irField->indexOffset) {
142 Logger::println("has union field offset"); 142 Logger::println("has union field offset");
143 ptr = DtoGEP(ptr, idxs, "tmp"); 143 ptr = DtoGEPi(ptr, idxs, "tmp");
144 if (ptr->getType() != llt) 144 if (ptr->getType() != llt)
145 ptr = DtoBitCast(ptr, llt); 145 ptr = DtoBitCast(ptr, llt);
146 ptr = llvm::GetElementPtrInst::Create(ptr, DtoConstUint(vd->ir.irField->indexOffset), "tmp", gIR->scopebb()); 146 ptr = llvm::GetElementPtrInst::Create(ptr, DtoConstUint(vd->ir.irField->indexOffset), "tmp", gIR->scopebb());
147 std::vector<unsigned> tmp; 147 DStructIndexVector tmp;
148 return DtoIndexStruct(ptr, ssd, t, os-vd->offset, tmp); 148 return DtoIndexStruct(ptr, ssd, t, os-vd->offset, tmp);
149 } 149 }
150 else { 150 else {
151 const LLType* sty = getPtrToType(DtoType(vd->type)); 151 const LLType* sty = getPtrToType(DtoType(vd->type));
152 if (ptr->getType() != sty) { 152 if (ptr->getType() != sty) {
153 ptr = DtoBitCast(ptr, sty); 153 ptr = DtoBitCast(ptr, sty);
154 std::vector<unsigned> tmp; 154 DStructIndexVector tmp;
155 return DtoIndexStruct(ptr, ssd, t, os-vd->offset, tmp); 155 return DtoIndexStruct(ptr, ssd, t, os-vd->offset, tmp);
156 } 156 }
157 else { 157 else {
158 return DtoIndexStruct(ptr, ssd, t, os-vd->offset, idxs); 158 return DtoIndexStruct(ptr, ssd, t, os-vd->offset, idxs);
159 } 159 }