comparison gen/structs.cpp @ 945:03d7c4aac654

SWITCHED TO LLVM 2.5 ! Applied patch from ticket #129 to compile against latest LLVM. Thanks Frits van Bommel. Fixed implicit return by asm block at the end of a function on x86-32. Other architectures will produce an error at the moment. Adding support for new targets is fairly simple. Fixed return calling convention for complex numbers, ST and ST(1) were switched around. Added some testcases. I've run a dstress test and there are no regressions. However, the runtime does not seem to compile with symbolic debug information. -O3 -release -inline works well and is what I used for the dstress run. Tango does not compile, a small workaround is needed in tango.io.digest.Digest.Digest.hexDigest. See ticket #206 .
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 08 Feb 2009 05:26:54 +0100
parents 39519a1ff603
children 9a10fa839dc5
comparison
equal deleted inserted replaced
944:eb310635d80e 945:03d7c4aac654
237 lastoffset = offset; 237 lastoffset = offset;
238 lastsize = size; 238 lastsize = size;
239 } 239 }
240 240
241 // there might still be padding after the last one, make sure that is defaulted/zeroed as well 241 // there might still be padding after the last one, make sure that is defaulted/zeroed as well
242 size_t structsize = getABITypeSize(structtype); 242 size_t structsize = getTypePaddedSize(structtype);
243 243
244 // if there is space before the next explicit initializer 244 // if there is space before the next explicit initializer
245 // FIXME: this should be handled in the loop above as well 245 // FIXME: this should be handled in the loop above as well
246 Lpadding2: 246 Lpadding2:
247 size_t pos = lastoffset+lastsize; 247 size_t pos = lastoffset+lastsize;
290 LLConstant* c = LLConstantStruct::get(inits, si->ad->ir.irStruct->packed); 290 LLConstant* c = LLConstantStruct::get(inits, si->ad->ir.irStruct->packed);
291 if (Logger::enabled()) 291 if (Logger::enabled())
292 { 292 {
293 Logger::cout() << "constant struct initializer: " << *c << '\n'; 293 Logger::cout() << "constant struct initializer: " << *c << '\n';
294 } 294 }
295 assert(getABITypeSize(c->getType()) == structsize); 295 assert(getTypePaddedSize(c->getType()) == structsize);
296 return c; 296 return c;
297 } 297 }
298 298
299 ////////////////////////////////////////////////////////////////////////////////////////// 299 //////////////////////////////////////////////////////////////////////////////////////////
300 300
404 //printf("added field: %s : %lu (%lu)\n", var->toChars(), os, sz); 404 //printf("added field: %s : %lu (%lu)\n", var->toChars(), os, sz);
405 } 405 }
406 406
407 // fill out rest with default initializers 407 // fill out rest with default initializers
408 const LLType* structtype = DtoType(sd->type); 408 const LLType* structtype = DtoType(sd->type);
409 size_t structsize = getABITypeSize(structtype); 409 size_t structsize = getTypePaddedSize(structtype);
410 410
411 // FIXME: this could probably share some code with the above 411 // FIXME: this could probably share some code with the above
412 if (structsize > lastoffset+lastsize) 412 if (structsize > lastoffset+lastsize)
413 { 413 {
414 for (/*continue from first loop*/; i < nvars; i++) 414 for (/*continue from first loop*/; i < nvars; i++)
556 VarDeclaration* v = (VarDeclaration*)fields->data[k]; 556 VarDeclaration* v = (VarDeclaration*)fields->data[k];
557 printf(" field: %s %s\n", v->type->toChars(), v->toChars()); 557 printf(" field: %s %s\n", v->type->toChars(), v->toChars());
558 printf(" index: %u offset: %u\n", v->ir.irField->index, v->ir.irField->unionOffset); 558 printf(" index: %u offset: %u\n", v->ir.irField->index, v->ir.irField->unionOffset);
559 } 559 }
560 560
561 unsigned llvmSize = (unsigned)getABITypeSize(ST); 561 unsigned llvmSize = (unsigned)getTypePaddedSize(ST);
562 unsigned dmdSize = (unsigned)sd->type->size(); 562 unsigned dmdSize = (unsigned)sd->type->size();
563 printf(" llvm size: %u dmd size: %u\n", llvmSize, dmdSize); 563 printf(" llvm size: %u dmd size: %u\n", llvmSize, dmdSize);
564 assert(llvmSize == dmdSize); 564 assert(llvmSize == dmdSize);
565 565
566 #endif 566 #endif
683 cmpop = llvm::ICmpInst::ICMP_EQ; 683 cmpop = llvm::ICmpInst::ICMP_EQ;
684 else 684 else
685 cmpop = llvm::ICmpInst::ICMP_NE; 685 cmpop = llvm::ICmpInst::ICMP_NE;
686 686
687 // call memcmp 687 // call memcmp
688 size_t sz = getABITypeSize(DtoType(t)); 688 size_t sz = getTypePaddedSize(DtoType(t));
689 LLValue* val = DtoMemCmp(lhs->getRVal(), rhs->getRVal(), DtoConstSize_t(sz)); 689 LLValue* val = DtoMemCmp(lhs->getRVal(), rhs->getRVal(), DtoConstSize_t(sz));
690 return gIR->ir->CreateICmp(cmpop, val, LLConstantInt::get(val->getType(), 0, false), "tmp"); 690 return gIR->ir->CreateICmp(cmpop, val, LLConstantInt::get(val->getType(), 0, false), "tmp");
691 } 691 }