Mercurial > projects > ldc
diff gen/llvmhelpers.cpp @ 610:1b62222581fb
Change bool type to i8
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 20 Sep 2008 10:13:15 +0200 |
parents | 1ecb43102d12 |
children | 83ca663ecc20 |
line wrap: on
line diff
--- a/gen/llvmhelpers.cpp Fri Sep 19 21:45:05 2008 +0200 +++ b/gen/llvmhelpers.cpp Sat Sep 20 10:13:15 2008 +0200 @@ -574,8 +574,8 @@ Type* from = val->getType()->toBasetype(); assert(from->isintegral()); - size_t fromsz = from->size(); - size_t tosz = to->size(); + size_t fromsz = getTypeBitSize(val->getRVal()->getType()); + size_t tosz = to->size()*8; LLValue* rval = val->getRVal(); if (rval->getType() == tolltype) { @@ -774,13 +774,13 @@ llvm::GlobalValue::LinkageTypes gflaglink = istempl ? llvm::GlobalValue::WeakLinkage : llvm::GlobalValue::InternalLinkage; std::string gflagname(gvar->getName()); gflagname.append("__initflag"); - llvm::GlobalVariable* gflag = new llvm::GlobalVariable(LLType::Int1Ty,false,gflaglink,DtoConstBool(false),gflagname,gIR->module); + llvm::GlobalVariable* gflag = new llvm::GlobalVariable(LLType::Int1Ty,false,gflaglink,DtoConstI1(false),gflagname,gIR->module); // check flag and do init if not already done llvm::BasicBlock* oldend = gIR->scopeend(); llvm::BasicBlock* initbb = llvm::BasicBlock::Create("ifnotinit",gIR->topfunc(),oldend); llvm::BasicBlock* endinitbb = llvm::BasicBlock::Create("ifnotinitend",gIR->topfunc(),oldend); - LLValue* cond = gIR->ir->CreateICmpEQ(gIR->ir->CreateLoad(gflag,"tmp"),DtoConstBool(false)); + LLValue* cond = gIR->ir->CreateICmpEQ(gIR->ir->CreateLoad(gflag,"tmp"),DtoConstI1(false)); gIR->ir->CreateCondBr(cond, initbb, endinitbb); gIR->scope() = IRScope(initbb,endinitbb); DValue* ie = DtoInitializer(gvar, init); @@ -788,7 +788,7 @@ DVarValue dst(t, gvar); DtoAssign(init->loc, &dst, ie); - gIR->ir->CreateStore(DtoConstBool(true), gflag); + gIR->ir->CreateStore(DtoConstI1(true), gflag); gIR->ir->CreateBr(endinitbb); gIR->scope() = IRScope(endinitbb,oldend); } @@ -1548,10 +1548,7 @@ Type* T = (Type*)ti->tdtypes.data[0]; char tmp[10]; - if (T->toBasetype()->ty == Tbool) // otherwise we'd get a mismatch - sprintf(tmp, "1"); - else - sprintf(tmp, "%d", T->size()*8); + sprintf(tmp, "%d", T->size()*8); // replace # in name with bitsize name = td->intrinsicName;