Mercurial > projects > ldc
comparison gen/typinf.c @ 71:53d3086b5ad3 trunk
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
author | lindquist |
---|---|
date | Sun, 28 Oct 2007 19:48:57 +0100 |
parents | 2b5a2eaa88be |
children | d7e764e62462 |
comparison
equal
deleted
inserted
replaced
70:fb265a6efea1 | 71:53d3086b5ad3 |
---|---|
412 char *name = sd->toPrettyChars(); | 412 char *name = sd->toPrettyChars(); |
413 sinits.push_back(LLVM_DtoConstString(name)); | 413 sinits.push_back(LLVM_DtoConstString(name)); |
414 assert(sinits.back()->getType() == initZ->getOperand(2)->getType()); | 414 assert(sinits.back()->getType() == initZ->getOperand(2)->getType()); |
415 | 415 |
416 // void[] init | 416 // void[] init |
417 //const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty); | 417 const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty); |
418 //sinits.push_back(LLVM_DtoConstantSlice(LLVM_DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); | 418 if (tinfo->isZeroInit() || !sd->defaultval) // 0 initializer, or the same as the base type |
419 sinits.push_back(initZ->getOperand(3)); | 419 { |
420 sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt))); | |
421 //sinits.push_back(initZ->getOperand(3)); | |
422 } | |
423 else | |
424 { | |
425 const llvm::Type* memty = LLVM_DtoType(sd->memtype); | |
426 llvm::Constant* ci = llvm::ConstantInt::get(memty, sd->defaultval, !sd->memtype->isunsigned()); | |
427 std::string ciname(sd->mangle()); | |
428 ciname.append("__init"); | |
429 llvm::GlobalVariable* civar = new llvm::GlobalVariable(memty,true,llvm::GlobalValue::InternalLinkage,ci,ciname,gIR->module); | |
430 llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(civar, initpt); | |
431 size_t cisize = gTargetData->getTypeSize(memty); | |
432 sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(cisize), cicast)); | |
433 } | |
420 | 434 |
421 // create the symbol | 435 // create the symbol |
422 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); | 436 llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); |
423 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::InternalLinkage,tiInit,toChars(),gIR->module); | 437 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::InternalLinkage,tiInit,toChars(),gIR->module); |
424 | 438 |