mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +03:00
Backed out changeset 1b62222581fb
Do not use i8 for bool. Instead rely on the target to store i1 as i8.
This commit is contained in:
parent
4b02533745
commit
bb47b7c4ce
7 changed files with 26 additions and 29 deletions
|
@ -153,6 +153,9 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value)
|
||||||
switch (arrayelemty->ty)
|
switch (arrayelemty->ty)
|
||||||
{
|
{
|
||||||
case Tbool:
|
case Tbool:
|
||||||
|
funcname = "_d_array_init_i1";
|
||||||
|
break;
|
||||||
|
|
||||||
case Tvoid:
|
case Tvoid:
|
||||||
case Tchar:
|
case Tchar:
|
||||||
case Tint8:
|
case Tint8:
|
||||||
|
|
|
@ -574,8 +574,8 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to)
|
||||||
Type* from = val->getType()->toBasetype();
|
Type* from = val->getType()->toBasetype();
|
||||||
assert(from->isintegral());
|
assert(from->isintegral());
|
||||||
|
|
||||||
size_t fromsz = getTypeBitSize(val->getRVal()->getType());
|
size_t fromsz = from->size();
|
||||||
size_t tosz = to->size()*8;
|
size_t tosz = to->size();
|
||||||
|
|
||||||
LLValue* rval = val->getRVal();
|
LLValue* rval = val->getRVal();
|
||||||
if (rval->getType() == tolltype) {
|
if (rval->getType() == tolltype) {
|
||||||
|
@ -774,13 +774,13 @@ void DtoLazyStaticInit(bool istempl, LLValue* gvar, Initializer* init, Type* t)
|
||||||
llvm::GlobalValue::LinkageTypes gflaglink = istempl ? llvm::GlobalValue::WeakLinkage : llvm::GlobalValue::InternalLinkage;
|
llvm::GlobalValue::LinkageTypes gflaglink = istempl ? llvm::GlobalValue::WeakLinkage : llvm::GlobalValue::InternalLinkage;
|
||||||
std::string gflagname(gvar->getName());
|
std::string gflagname(gvar->getName());
|
||||||
gflagname.append("__initflag");
|
gflagname.append("__initflag");
|
||||||
llvm::GlobalVariable* gflag = new llvm::GlobalVariable(LLType::Int1Ty,false,gflaglink,DtoConstI1(false),gflagname,gIR->module);
|
llvm::GlobalVariable* gflag = new llvm::GlobalVariable(LLType::Int1Ty,false,gflaglink,DtoConstBool(false),gflagname,gIR->module);
|
||||||
|
|
||||||
// check flag and do init if not already done
|
// check flag and do init if not already done
|
||||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||||
llvm::BasicBlock* initbb = llvm::BasicBlock::Create("ifnotinit",gIR->topfunc(),oldend);
|
llvm::BasicBlock* initbb = llvm::BasicBlock::Create("ifnotinit",gIR->topfunc(),oldend);
|
||||||
llvm::BasicBlock* endinitbb = llvm::BasicBlock::Create("ifnotinitend",gIR->topfunc(),oldend);
|
llvm::BasicBlock* endinitbb = llvm::BasicBlock::Create("ifnotinitend",gIR->topfunc(),oldend);
|
||||||
LLValue* cond = gIR->ir->CreateICmpEQ(gIR->ir->CreateLoad(gflag,"tmp"),DtoConstI1(false));
|
LLValue* cond = gIR->ir->CreateICmpEQ(gIR->ir->CreateLoad(gflag,"tmp"),DtoConstBool(false));
|
||||||
gIR->ir->CreateCondBr(cond, initbb, endinitbb);
|
gIR->ir->CreateCondBr(cond, initbb, endinitbb);
|
||||||
gIR->scope() = IRScope(initbb,endinitbb);
|
gIR->scope() = IRScope(initbb,endinitbb);
|
||||||
DValue* ie = DtoInitializer(gvar, init);
|
DValue* ie = DtoInitializer(gvar, init);
|
||||||
|
@ -788,7 +788,7 @@ void DtoLazyStaticInit(bool istempl, LLValue* gvar, Initializer* init, Type* t)
|
||||||
DVarValue dst(t, gvar);
|
DVarValue dst(t, gvar);
|
||||||
DtoAssign(init->loc, &dst, ie);
|
DtoAssign(init->loc, &dst, ie);
|
||||||
|
|
||||||
gIR->ir->CreateStore(DtoConstI1(true), gflag);
|
gIR->ir->CreateStore(DtoConstBool(true), gflag);
|
||||||
gIR->ir->CreateBr(endinitbb);
|
gIR->ir->CreateBr(endinitbb);
|
||||||
gIR->scope() = IRScope(endinitbb,oldend);
|
gIR->scope() = IRScope(endinitbb,oldend);
|
||||||
}
|
}
|
||||||
|
@ -1548,6 +1548,9 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s
|
||||||
Type* T = (Type*)ti->tdtypes.data[0];
|
Type* T = (Type*)ti->tdtypes.data[0];
|
||||||
|
|
||||||
char tmp[10];
|
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
|
// replace # in name with bitsize
|
||||||
|
|
|
@ -81,15 +81,11 @@ void ReturnStatement::toIR(IRState* p)
|
||||||
delete e;
|
delete e;
|
||||||
Logger::cout() << "return value is '" <<*v << "'\n";
|
Logger::cout() << "return value is '" <<*v << "'\n";
|
||||||
|
|
||||||
|
// can happen for classes
|
||||||
if (v->getType() != p->topfunc()->getReturnType())
|
if (v->getType() != p->topfunc()->getReturnType())
|
||||||
{
|
{
|
||||||
// can happen for classes
|
|
||||||
if(isaPointer(v) && isaPointer(p->topfunc()->getReturnType()))
|
|
||||||
v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp");
|
v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp");
|
||||||
// or for i1 vs i8 bools
|
Logger::cout() << "return value after cast: " << *v << '\n';
|
||||||
if(v->getType() == LLType::Int1Ty && p->topfunc()->getReturnType() == LLType::Int8Ty)
|
|
||||||
v = gIR->ir->CreateZExt(v, LLType::Int8Ty);
|
|
||||||
Logger::cout() << "adjusted return value: " << *v << '\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DtoEnclosingHandlers(enclosinghandler, NULL);
|
DtoEnclosingHandlers(enclosinghandler, NULL);
|
||||||
|
|
|
@ -162,8 +162,8 @@ static LLGlobalVariable* dwarfSubProgram(FuncDeclaration* fd, llvm::GlobalVariab
|
||||||
vals[6] = DBG_CAST( DtoDwarfCompileUnit(fd->getModule()) );
|
vals[6] = DBG_CAST( DtoDwarfCompileUnit(fd->getModule()) );
|
||||||
vals[7] = DtoConstUint(fd->loc.linnum);
|
vals[7] = DtoConstUint(fd->loc.linnum);
|
||||||
vals[8] = DBG_NULL;
|
vals[8] = DBG_NULL;
|
||||||
vals[9] = DtoConstI1(fd->protection == PROTprivate);
|
vals[9] = DtoConstBool(fd->protection == PROTprivate);
|
||||||
vals[10] = DtoConstI1(fd->getModule() == gIR->dmodule);
|
vals[10] = DtoConstBool(fd->getModule() == gIR->dmodule);
|
||||||
|
|
||||||
Logger::println("emitting subprogram global");
|
Logger::println("emitting subprogram global");
|
||||||
|
|
||||||
|
@ -519,8 +519,8 @@ static LLGlobalVariable* dwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaratio
|
||||||
|
|
||||||
LLGlobalVariable* TY = dwarfTypeDescription_impl(vd->type, compileUnit, NULL);
|
LLGlobalVariable* TY = dwarfTypeDescription_impl(vd->type, compileUnit, NULL);
|
||||||
vals[8] = TY ? DBG_CAST(TY) : DBG_NULL;
|
vals[8] = TY ? DBG_CAST(TY) : DBG_NULL;
|
||||||
vals[9] = DtoConstI1(vd->protection == PROTprivate);
|
vals[9] = DtoConstBool(vd->protection == PROTprivate);
|
||||||
vals[10] = DtoConstI1(vd->getModule() == gIR->dmodule);
|
vals[10] = DtoConstBool(vd->getModule() == gIR->dmodule);
|
||||||
|
|
||||||
vals[11] = DBG_CAST(ll);
|
vals[11] = DBG_CAST(ll);
|
||||||
|
|
||||||
|
|
|
@ -1649,7 +1649,7 @@ DValue* NotExp::toElem(IRState* p)
|
||||||
|
|
||||||
LLValue* b = DtoBoolean(loc, u);
|
LLValue* b = DtoBoolean(loc, u);
|
||||||
|
|
||||||
LLConstant* zero = llvm::ConstantInt::get(b->getType(), 0);
|
LLConstant* zero = DtoConstBool(false);
|
||||||
b = p->ir->CreateICmpEQ(b,zero);
|
b = p->ir->CreateICmpEQ(b,zero);
|
||||||
|
|
||||||
return new DImValue(type, b);
|
return new DImValue(type, b);
|
||||||
|
|
|
@ -77,7 +77,7 @@ const LLType* DtoType(Type* t)
|
||||||
return (const LLType*)LLType::Int64Ty;
|
return (const LLType*)LLType::Int64Ty;
|
||||||
|
|
||||||
case Tbool:
|
case Tbool:
|
||||||
return (const LLType*)LLType::Int8Ty;
|
return (const LLType*)llvm::ConstantInt::getTrue()->getType();
|
||||||
|
|
||||||
// floats
|
// floats
|
||||||
case Tfloat32:
|
case Tfloat32:
|
||||||
|
@ -462,11 +462,11 @@ void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device)
|
||||||
assert(fn != NULL);
|
assert(fn != NULL);
|
||||||
|
|
||||||
LLSmallVector<LLValue*, 5> llargs;
|
LLSmallVector<LLValue*, 5> llargs;
|
||||||
llargs.push_back(DtoConstI1(ll));
|
llargs.push_back(DtoConstBool(ll));
|
||||||
llargs.push_back(DtoConstI1(ls));
|
llargs.push_back(DtoConstBool(ls));
|
||||||
llargs.push_back(DtoConstI1(sl));
|
llargs.push_back(DtoConstBool(sl));
|
||||||
llargs.push_back(DtoConstI1(ss));
|
llargs.push_back(DtoConstBool(ss));
|
||||||
llargs.push_back(DtoConstI1(device));
|
llargs.push_back(DtoConstBool(device));
|
||||||
|
|
||||||
llvm::CallInst::Create(fn, llargs.begin(), llargs.end(), "", gIR->scopebb());
|
llvm::CallInst::Create(fn, llargs.begin(), llargs.end(), "", gIR->scopebb());
|
||||||
}
|
}
|
||||||
|
@ -486,10 +486,6 @@ llvm::ConstantInt* DtoConstInt(int i)
|
||||||
return llvm::ConstantInt::get(LLType::Int32Ty, i, true);
|
return llvm::ConstantInt::get(LLType::Int32Ty, i, true);
|
||||||
}
|
}
|
||||||
LLConstant* DtoConstBool(bool b)
|
LLConstant* DtoConstBool(bool b)
|
||||||
{
|
|
||||||
return llvm::ConstantInt::get(LLType::Int8Ty, b, false);
|
|
||||||
}
|
|
||||||
LLConstant* DtoConstI1(bool b)
|
|
||||||
{
|
{
|
||||||
return llvm::ConstantInt::get(LLType::Int1Ty, b, false);
|
return llvm::ConstantInt::get(LLType::Int1Ty, b, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@ llvm::ConstantFP* DtoConstFP(Type* t, long double value);
|
||||||
LLConstant* DtoConstString(const char*);
|
LLConstant* DtoConstString(const char*);
|
||||||
LLConstant* DtoConstStringPtr(const char* str, const char* section = 0);
|
LLConstant* DtoConstStringPtr(const char* str, const char* section = 0);
|
||||||
LLConstant* DtoConstBool(bool);
|
LLConstant* DtoConstBool(bool);
|
||||||
LLConstant* DtoConstI1(bool);
|
|
||||||
|
|
||||||
// llvm wrappers
|
// llvm wrappers
|
||||||
LLValue* DtoLoad(LLValue* src, const char* name=0);
|
LLValue* DtoLoad(LLValue* src, const char* name=0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue