mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-30 07:00:46 +03:00
Use llvm_unreachable instead of assert(0).
Also removed some unused functions.
This commit is contained in:
parent
28a65ff689
commit
8ff3a8060a
18 changed files with 68 additions and 166 deletions
|
@ -139,7 +139,7 @@ void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostrea
|
||||||
|
|
||||||
llvm::formatted_raw_ostream fout(out);
|
llvm::formatted_raw_ostream fout(out);
|
||||||
if (Target.addPassesToEmitFile(Passes, fout, fileType, codeGenOptLevel()))
|
if (Target.addPassesToEmitFile(Passes, fout, fileType, codeGenOptLevel()))
|
||||||
assert(0 && "no support for asm output");
|
llvm_unreachable("no support for asm output");
|
||||||
|
|
||||||
Passes.doInitialization();
|
Passes.doInitialization();
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ namespace {
|
||||||
return const_cast<LLType*>(LLType::getX86_FP80Ty(gIR->context()));
|
return const_cast<LLType*>(LLType::getX86_FP80Ty(gIR->context()));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unanticipated argument class");
|
llvm_unreachable("Unanticipated argument class.");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(cl.classes[1]) {
|
switch(cl.classes[1]) {
|
||||||
|
@ -291,7 +291,7 @@ namespace {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unanticipated argument class for second half");
|
llvm_unreachable("Unanticipated argument class for second half.");
|
||||||
}
|
}
|
||||||
return LLStructType::get(gIR->context(), parts);
|
return LLStructType::get(gIR->context(), parts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1207,8 +1207,7 @@ LLValue* DtoArrayLen(DValue* v)
|
||||||
TypeSArray *sarray = static_cast<TypeSArray*>(v->type->toBasetype());
|
TypeSArray *sarray = static_cast<TypeSArray*>(v->type->toBasetype());
|
||||||
return DtoConstSize_t(sarray->dim->toUInteger());
|
return DtoConstSize_t(sarray->dim->toUInteger());
|
||||||
}
|
}
|
||||||
assert(0 && "unsupported array for len");
|
llvm_unreachable("unsupported array for len");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1232,8 +1231,8 @@ LLValue* DtoArrayPtr(DValue* v)
|
||||||
assert(!v->isNull());
|
assert(!v->isNull());
|
||||||
return DtoGEPi(v->getRVal(), 0,0);
|
return DtoGEPi(v->getRVal(), 0,0);
|
||||||
}
|
}
|
||||||
assert(0);
|
|
||||||
return 0;
|
llvm_unreachable("Unexpected array type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -275,12 +275,12 @@ AsmStatement::toIR(IRState * irs)
|
||||||
case Mode_Input: cns = m_cns; break;
|
case Mode_Input: cns = m_cns; break;
|
||||||
case Mode_Output: cns = mw_cns; is_input = false; break;
|
case Mode_Output: cns = mw_cns; is_input = false; break;
|
||||||
case Mode_Update: cns = mrw_cns; is_input = false; break;
|
case Mode_Update: cns = mrw_cns; is_input = false; break;
|
||||||
default: assert(0); break;
|
default: llvm_unreachable("Unknown inline asm reference mode."); break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Arg_FrameRelative:
|
case Arg_FrameRelative:
|
||||||
// FIXME
|
// FIXME
|
||||||
assert(0 && "asm fixme Arg_FrameRelative");
|
llvm_unreachable("Arg_FrameRelative not supported.");
|
||||||
/* if (arg->expr->op == TOKvar)
|
/* if (arg->expr->op == TOKvar)
|
||||||
arg_val = ((VarExp *) arg->expr)->var->toSymbol()->Stree;
|
arg_val = ((VarExp *) arg->expr)->var->toSymbol()->Stree;
|
||||||
else
|
else
|
||||||
|
@ -296,15 +296,15 @@ assert(0 && "asm fixme Arg_FrameRelative");
|
||||||
clobbers_mem = true;
|
clobbers_mem = true;
|
||||||
break;*/
|
break;*/
|
||||||
case Arg_LocalSize:
|
case Arg_LocalSize:
|
||||||
// FIXME
|
// FIXME
|
||||||
assert(0 && "asm fixme Arg_LocalSize");
|
llvm_unreachable("Arg_LocalSize not supported.");
|
||||||
/* var_frame_offset = cfun->x_frame_offset;
|
/* var_frame_offset = cfun->x_frame_offset;
|
||||||
if (var_frame_offset < 0)
|
if (var_frame_offset < 0)
|
||||||
var_frame_offset = - var_frame_offset;
|
var_frame_offset = - var_frame_offset;
|
||||||
arg_val = irs->integerConstant( var_frame_offset );*/
|
arg_val = irs->integerConstant( var_frame_offset );*/
|
||||||
goto do_integer;
|
goto do_integer;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
llvm_unreachable("Unknown inline asm reference type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_input) {
|
if (is_input) {
|
||||||
|
|
|
@ -68,22 +68,6 @@ LLConstant* DtoConstComplex(Type* _ty, longdouble re, longdouble im)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
LLValue* DtoRealPart(DValue* val)
|
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
return gIR->ir->CreateExtractElement(val->getRVal(), DtoConstUint(0), "tmp");
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
LLValue* DtoImagPart(DValue* val)
|
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
return gIR->ir->CreateExtractElement(val->getRVal(), DtoConstUint(1), "tmp");
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
DValue* DtoComplex(Loc& loc, Type* to, DValue* val)
|
DValue* DtoComplex(Loc& loc, Type* to, DValue* val)
|
||||||
{
|
{
|
||||||
LLType* complexTy = DtoType(to);
|
LLType* complexTy = DtoType(to);
|
||||||
|
@ -181,7 +165,7 @@ void DtoGetComplexParts(Loc& loc, Type* to, DValue* val, DValue*& re, DValue*& i
|
||||||
im = NULL;
|
im = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(0);
|
llvm_unreachable("Unexpected numeric type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +344,7 @@ DValue* DtoComplexDiv(Loc& loc, Type* type, DValue* lhs, DValue* rhs)
|
||||||
res_im = gIR->ir->CreateFMul(lhs_im, rhs_re, "imre");
|
res_im = gIR->ir->CreateFMul(lhs_im, rhs_re, "imre");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assert(0 && "lhs has neither real nor imaginary part");
|
llvm_unreachable("lhs has neither real nor imaginary part");
|
||||||
|
|
||||||
tmp1 = gIR->ir->CreateFMul(rhs_re, rhs_re, "rhs_resq");
|
tmp1 = gIR->ir->CreateFMul(rhs_re, rhs_re, "rhs_resq");
|
||||||
tmp2 = gIR->ir->CreateFMul(rhs_im, rhs_im, "rhs_imsq");
|
tmp2 = gIR->ir->CreateFMul(rhs_im, rhs_im, "rhs_imsq");
|
||||||
|
|
|
@ -21,8 +21,6 @@ LLConstant* DtoConstComplex(Type* t, longdouble re, longdouble im);
|
||||||
|
|
||||||
LLConstant* DtoComplexShuffleMask(unsigned a, unsigned b);
|
LLConstant* DtoComplexShuffleMask(unsigned a, unsigned b);
|
||||||
|
|
||||||
LLValue* DtoRealPart(DValue* val);
|
|
||||||
LLValue* DtoImagPart(DValue* val);
|
|
||||||
DValue* DtoComplex(Loc& loc, Type* to, DValue* val);
|
DValue* DtoComplex(Loc& loc, Type* to, DValue* val);
|
||||||
|
|
||||||
void DtoComplexSet(LLValue* c, LLValue* re, LLValue* im);
|
void DtoComplexSet(LLValue* c, LLValue* re, LLValue* im);
|
||||||
|
|
|
@ -137,10 +137,8 @@ void VarDeclaration::codegen(Ir* p)
|
||||||
Logger::println("data segment");
|
Logger::println("data segment");
|
||||||
|
|
||||||
#if DMDV2 && 0 // TODO:
|
#if DMDV2 && 0 // TODO:
|
||||||
if (storage_class & STCmanifest)
|
assert(!(storage_class & STCmanifest) &&
|
||||||
{
|
"manifest constant being codegen'd!");
|
||||||
assert(0 && "manifest constant being codegened!!!");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// don't duplicate work
|
// don't duplicate work
|
||||||
|
|
|
@ -444,7 +444,7 @@ llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger::println("chars: %s type: %s kind: %s", fdecl->toChars(), fdecl->type->toChars(), fdecl->kind());
|
Logger::println("chars: %s type: %s kind: %s", fdecl->toChars(), fdecl->type->toChars(), fdecl->kind());
|
||||||
assert(0);
|
llvm_unreachable("needThis, but invalid parent declaration.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fdecl->isNested()) {
|
else if (fdecl->isNested()) {
|
||||||
|
|
|
@ -477,9 +477,7 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPostblit)
|
||||||
// T[n] = T[] - generally only generated by frontend in rare cases
|
// T[n] = T[] - generally only generated by frontend in rare cases
|
||||||
else if (t2->ty == Tarray && t->nextOf()->toBasetype()->equals(t2->nextOf()->toBasetype())) {
|
else if (t2->ty == Tarray && t->nextOf()->toBasetype()->equals(t2->nextOf()->toBasetype())) {
|
||||||
DtoMemCpy(lhs->getLVal(), DtoArrayPtr(rhs), DtoArrayLen(rhs));
|
DtoMemCpy(lhs->getLVal(), DtoArrayPtr(rhs), DtoArrayLen(rhs));
|
||||||
} else {
|
} else llvm_unreachable("Unimplemented static array assign!");
|
||||||
assert(0 && "Unimplemented static array assign!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (t->ty == Tdelegate) {
|
else if (t->ty == Tdelegate) {
|
||||||
LLValue* l = lhs->getLVal();
|
LLValue* l = lhs->getLVal();
|
||||||
|
@ -575,11 +573,7 @@ DValue* DtoNullValue(Type* type)
|
||||||
return new DNullValue(type, LLConstant::getNullValue(lltype));
|
return new DNullValue(type, LLConstant::getNullValue(lltype));
|
||||||
}
|
}
|
||||||
|
|
||||||
// unknown
|
llvm_unreachable("null not known for this type.");
|
||||||
error("unsupported: null value for %s", type->toChars());
|
|
||||||
assert(0);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1009,8 +1003,7 @@ void DtoResolveDsymbol(Dsymbol* dsym)
|
||||||
DtoResolveTypeInfo(fd);
|
DtoResolveTypeInfo(fd);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error(dsym->loc, "unsupported dsymbol: %s", dsym->toChars());
|
llvm_unreachable("Unsupported DSymbol for DtoResolveDsymbol.");
|
||||||
assert(0 && "unsupported dsymbol for DtoResolveDsymbol");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1256,11 +1249,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
||||||
else if (TupleDeclaration* tupled = declaration->isTupleDeclaration())
|
else if (TupleDeclaration* tupled = declaration->isTupleDeclaration())
|
||||||
{
|
{
|
||||||
Logger::println("TupleDeclaration");
|
Logger::println("TupleDeclaration");
|
||||||
if(!tupled->isexp) {
|
assert(tupled->isexp && "Non-expression tuple decls not handled yet.");
|
||||||
error(declaration->loc, "don't know how to handle non-expression tuple decls yet");
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(tupled->objects);
|
assert(tupled->objects);
|
||||||
for (unsigned i=0; i < tupled->objects->dim; ++i)
|
for (unsigned i=0; i < tupled->objects->dim; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1274,13 +1263,10 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
||||||
Logger::println("TemplateDeclaration");
|
Logger::println("TemplateDeclaration");
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
// unsupported declaration
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
error(declaration->loc, "Unimplemented Declaration type for DeclarationExp. kind: %s", declaration->kind());
|
llvm_unreachable("Unimplemented Declaration type for DeclarationExp.");
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// does pretty much the same as DtoDeclarationExp, except it doesn't initialize, and only handles var declarations
|
// does pretty much the same as DtoDeclarationExp, except it doesn't initialize, and only handles var declarations
|
||||||
|
@ -1462,14 +1448,14 @@ DValue* DtoInitializer(LLValue* target, Initializer* init)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
else if (init->isStructInitializer()) {
|
else if (init->isStructInitializer())
|
||||||
|
{
|
||||||
// TODO: again nothing ?
|
// TODO: again nothing ?
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
Logger::println("unsupported initializer: %s", init->toChars());
|
{
|
||||||
assert(0);
|
llvm_unreachable("Unknown initializer type.");
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1538,8 +1524,9 @@ LLConstant* DtoConstExpInit(Loc loc, Type* type, Expression* exp)
|
||||||
Logger::println("type is a static array, building constant array initializer to single value");
|
Logger::println("type is a static array, building constant array initializer to single value");
|
||||||
return expand_to_sarray(base, exp);
|
return expand_to_sarray(base, exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
else if (base->ty == Tvector)
|
if (base->ty == Tvector)
|
||||||
{
|
{
|
||||||
LLConstant* val = exp->toConstElem(gIR);
|
LLConstant* val = exp->toConstElem(gIR);
|
||||||
TypeVector* tv = (TypeVector*)base;
|
TypeVector* tv = (TypeVector*)base;
|
||||||
|
@ -1551,13 +1538,10 @@ LLConstant* DtoConstExpInit(Loc loc, Type* type, Expression* exp)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
|
||||||
{
|
|
||||||
error(loc, "LDC internal error: cannot yet convert default initializer %s of type %s to %s",
|
error(loc, "LDC internal error: cannot yet convert default initializer %s of type %s to %s",
|
||||||
exp->toChars(), exp->type->toChars(), type->toChars());
|
exp->toChars(), exp->type->toChars(), type->toChars());
|
||||||
fatal();
|
llvm_unreachable("Unsupported default initializer.");
|
||||||
}
|
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return exp->toConstElem(gIR);
|
return exp->toConstElem(gIR);
|
||||||
|
|
|
@ -658,14 +658,6 @@ void Module::genmoduleinfo()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*Logger::println("MODULE INFO INITIALIZERS");
|
|
||||||
for (size_t i=0; i<initVec.size(); ++i)
|
|
||||||
{
|
|
||||||
Logger::cout() << *initVec[i] << '\n';
|
|
||||||
if (initVec[i]->getType() != moduleinfoTy->getElementType(i))
|
|
||||||
assert(0);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// create and set initializer
|
// create and set initializer
|
||||||
b.finalize(moduleInfoType, moduleInfoSymbol());
|
b.finalize(moduleInfoType, moduleInfoSymbol());
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,7 @@ llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name
|
||||||
return fn;
|
return fn;
|
||||||
|
|
||||||
fn = M->getFunction(name);
|
fn = M->getFunction(name);
|
||||||
if (!fn) {
|
assert(fn && "Runtime function not found.");
|
||||||
printf("Runtime function '%s' was not found\n", name);
|
|
||||||
assert(0);
|
|
||||||
//return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
LLFunctionType* fnty = fn->getFunctionType();
|
LLFunctionType* fnty = fn->getFunctionType();
|
||||||
LLFunction* resfn = llvm::cast<llvm::Function>(target->getOrInsertFunction(name, fnty));
|
LLFunction* resfn = llvm::cast<llvm::Function>(target->getOrInsertFunction(name, fnty));
|
||||||
|
|
|
@ -52,8 +52,7 @@ TypeFunction* DtoTypeFunction(DValue* fnval)
|
||||||
return static_cast<TypeFunction*>(next);
|
return static_cast<TypeFunction*>(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0 && "cant get TypeFunction* from non lazy/function/delegate");
|
llvm_unreachable("Cannot get TypeFunction* from non lazy/function/delegate");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -123,11 +122,8 @@ LLValue* DtoCallableValue(DValue* fn)
|
||||||
return gIR->ir->CreateExtractValue(dg, 1, ".funcptr");
|
return gIR->ir->CreateExtractValue(dg, 1, ".funcptr");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
llvm_unreachable("Not a callable type.");
|
||||||
assert(0 && "not a callable type");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -101,7 +101,7 @@ static llvm::DIType dwarfBasicType(Type* type)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(0 && "unsupported basictype for debug info");
|
llvm_unreachable("unsupported basic type for debug info");
|
||||||
}
|
}
|
||||||
|
|
||||||
return gIR->dibuilder.createBasicType(
|
return gIR->dibuilder.createBasicType(
|
||||||
|
|
51
gen/toir.cpp
51
gen/toir.cpp
|
@ -211,7 +211,7 @@ DValue* VarExp::toElem(IRState* p)
|
||||||
else if (llvm::isa<llvm::Argument>(vd->ir.getIrValue())) {
|
else if (llvm::isa<llvm::Argument>(vd->ir.getIrValue())) {
|
||||||
return new DImValue(type, vd->ir.getIrValue());
|
return new DImValue(type, vd->ir.getIrValue());
|
||||||
}
|
}
|
||||||
else assert(0);
|
else llvm_unreachable("Unexpected parameter value.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger::println("a normal variable");
|
Logger::println("a normal variable");
|
||||||
|
@ -271,7 +271,7 @@ DValue* VarExp::toElem(IRState* p)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(0 && "Unimplemented VarExp type");
|
llvm_unreachable("Unimplemented VarExp type");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -399,8 +399,8 @@ LLConstant* NullExp::toConstElem(IRState* p)
|
||||||
else {
|
else {
|
||||||
return LLConstant::getNullValue(t);
|
return LLConstant::getNullValue(t);
|
||||||
}
|
}
|
||||||
assert(0);
|
|
||||||
return NULL;
|
llvm_unreachable("Unknown type for null constant.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -504,8 +504,7 @@ DValue* StringExp::toElem(IRState* p)
|
||||||
return new DImValue(type, arrptr);
|
return new DImValue(type, arrptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0);
|
llvm_unreachable("Unknown type for StringExp.");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -560,8 +559,7 @@ LLConstant* StringExp::toConstElem(IRState* p)
|
||||||
return DtoConstSlice(clen, arrptr, type);
|
return DtoConstSlice(clen, arrptr, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0);
|
llvm_unreachable("Unknown type for StringExp.");
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1229,8 +1227,7 @@ DValue* SymOffExp::toElem(IRState* p)
|
||||||
Logger::print("SymOffExp::toElem: %s @ %s\n", toChars(), type->toChars());
|
Logger::print("SymOffExp::toElem: %s @ %s\n", toChars(), type->toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
assert(0 && "SymOffExp::toElem should no longer be called :/");
|
llvm_unreachable("SymOffExp::toElem should no longer be called.");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1454,7 +1451,7 @@ DValue* DotVarExp::toElem(IRState* p)
|
||||||
arrptr = DtoIndexClass(l->getRVal(), tc->sym, vd);
|
arrptr = DtoIndexClass(l->getRVal(), tc->sym, vd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assert(0);
|
llvm_unreachable("Unknown DotVarExp type for VarDeclaration.");
|
||||||
|
|
||||||
//Logger::cout() << "mem: " << *arrptr << '\n';
|
//Logger::cout() << "mem: " << *arrptr << '\n';
|
||||||
return new DVarValue(type, vd, arrptr);
|
return new DVarValue(type, vd, arrptr);
|
||||||
|
@ -1513,12 +1510,8 @@ DValue* DotVarExp::toElem(IRState* p)
|
||||||
|
|
||||||
return new DFuncValue(fdecl, funcval, passedThis);
|
return new DFuncValue(fdecl, funcval, passedThis);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
printf("unsupported dotvarexp: %s\n", var->toChars());
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(0);
|
llvm_unreachable("Unknown target for VarDeclaration.");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1557,9 +1550,7 @@ DValue* ThisExp::toElem(IRState* p)
|
||||||
return new DVarValue(type, vd, v);
|
return new DVarValue(type, vd, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// anything we're not yet handling ?
|
llvm_unreachable("No VarDeclaration in ThisExp.");
|
||||||
assert(0 && "no var in ThisExp");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1611,8 +1602,8 @@ DValue* IndexExp::toElem(IRState* p)
|
||||||
return DtoAAIndex(loc, type, l, r, modifiable);
|
return DtoAAIndex(loc, type, l, r, modifiable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger::println("invalid index exp! e1type: %s", e1type->toChars());
|
Logger::println("e1type: %s", e1type->toChars());
|
||||||
assert(0);
|
llvm_unreachable("Unknown IndexExp target.");
|
||||||
}
|
}
|
||||||
return new DVarValue(type, arrptr);
|
return new DVarValue(type, arrptr);
|
||||||
}
|
}
|
||||||
|
@ -1762,7 +1753,7 @@ DValue* CmpExp::toElem(IRState* p)
|
||||||
cmpop = llvm::FCmpInst::FCMP_ORD;break;
|
cmpop = llvm::FCmpInst::FCMP_ORD;break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
llvm_unreachable("Unsupported floating point comparison operator.");
|
||||||
}
|
}
|
||||||
eval = p->ir->CreateFCmp(cmpop, l->getRVal(), r->getRVal(), "tmp");
|
eval = p->ir->CreateFCmp(cmpop, l->getRVal(), r->getRVal(), "tmp");
|
||||||
}
|
}
|
||||||
|
@ -1821,7 +1812,7 @@ DValue* CmpExp::toElem(IRState* p)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(0 && "Unsupported CmpExp type");
|
llvm_unreachable("Unsupported CmpExp type");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DImValue(type, eval);
|
return new DImValue(type, eval);
|
||||||
|
@ -1858,7 +1849,7 @@ DValue* EqualExp::toElem(IRState* p)
|
||||||
cmpop = llvm::ICmpInst::ICMP_NE;
|
cmpop = llvm::ICmpInst::ICMP_NE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
llvm_unreachable("Unsupported integral type equality comparison.");
|
||||||
}
|
}
|
||||||
if (rv->getType() != lv->getType()) {
|
if (rv->getType() != lv->getType()) {
|
||||||
rv = DtoBitCast(rv, lv->getType());
|
rv = DtoBitCast(rv, lv->getType());
|
||||||
|
@ -1897,7 +1888,7 @@ DValue* EqualExp::toElem(IRState* p)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(0 && "Unsupported EqualExp type");
|
llvm_unreachable("Unsupported EqualExp type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DImValue(type, eval);
|
return new DImValue(type, eval);
|
||||||
|
@ -1997,7 +1988,7 @@ DValue* NewExp::toElem(IRState* p)
|
||||||
// new static array
|
// new static array
|
||||||
else if (ntype->ty == Tsarray)
|
else if (ntype->ty == Tsarray)
|
||||||
{
|
{
|
||||||
assert(0);
|
llvm_unreachable("Static array new should decay to dynamic array.");
|
||||||
}
|
}
|
||||||
// new struct
|
// new struct
|
||||||
else if (ntype->ty == Tstruct)
|
else if (ntype->ty == Tstruct)
|
||||||
|
@ -2062,7 +2053,7 @@ DValue* NewExp::toElem(IRState* p)
|
||||||
return new DImValue(type, mem);
|
return new DImValue(type, mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0);
|
llvm_unreachable(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -2127,7 +2118,7 @@ DValue* DeleteExp::toElem(IRState* p)
|
||||||
// unknown/invalid
|
// unknown/invalid
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(0 && "invalid delete");
|
llvm_unreachable("Unsupported DeleteExp target.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// no value to return
|
// no value to return
|
||||||
|
@ -2442,9 +2433,9 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||||
if (e1->op != TOKsuper && e1->op != TOKdottype && func->isVirtual() && !func->isFinal())
|
if (e1->op != TOKsuper && e1->op != TOKdottype && func->isVirtual() && !func->isFinal())
|
||||||
castfptr = DtoVirtualFunctionPointer(u, func, toChars());
|
castfptr = DtoVirtualFunctionPointer(u, func, toChars());
|
||||||
else if (func->isAbstract())
|
else if (func->isAbstract())
|
||||||
assert(0 && "TODO delegate to abstract method");
|
llvm_unreachable("Delegate to abstract method not implemented.");
|
||||||
else if (func->toParent()->isInterfaceDeclaration())
|
else if (func->toParent()->isInterfaceDeclaration())
|
||||||
assert(0 && "TODO delegate to interface method");
|
llvm_unreachable("Delegate to interface method not implemented.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
func->codegen(Type::sir);
|
func->codegen(Type::sir);
|
||||||
|
|
|
@ -74,6 +74,9 @@ llvm::Attributes DtoShouldExtend(Type* type)
|
||||||
#else
|
#else
|
||||||
return llvm::Attribute::ZExt;
|
return llvm::Attribute::ZExt;
|
||||||
#endif
|
#endif
|
||||||
|
default:
|
||||||
|
// Do not extend.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
|
@ -221,8 +224,7 @@ LLType* DtoType(Type* t)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("trying to convert unknown type '%s' with value %d\n", t->toChars(), t->ty);
|
llvm_unreachable("Unknown class of D Type!");
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +365,7 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(0 && "not global/function");
|
llvm_unreachable("not global/function");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the function needs to be defined in the current module, check if it
|
// If the function needs to be defined in the current module, check if it
|
||||||
|
@ -463,40 +465,6 @@ llvm::GlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
LLValue* DtoPointedType(LLValue* ptr, LLValue* val)
|
|
||||||
{
|
|
||||||
LLType* ptrTy = ptr->getType()->getContainedType(0);
|
|
||||||
LLType* valTy = val->getType();
|
|
||||||
// ptr points to val's type
|
|
||||||
if (ptrTy == valTy)
|
|
||||||
{
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
// ptr is integer pointer
|
|
||||||
else if (ptrTy->isIntegerTy())
|
|
||||||
{
|
|
||||||
// val is integer
|
|
||||||
assert(valTy->isIntegerTy());
|
|
||||||
LLIntegerType* pt = llvm::cast<LLIntegerType>(ptrTy);
|
|
||||||
LLIntegerType* vt = llvm::cast<LLIntegerType>(valTy);
|
|
||||||
if (pt->getBitWidth() < vt->getBitWidth()) {
|
|
||||||
return new llvm::TruncInst(val, pt, "tmp", gIR->scopebb());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
// something else unsupported
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Logger::enabled())
|
|
||||||
Logger::cout() << *ptrTy << '|' << *valTy << '\n';
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
LLIntegerType* DtoSize_t()
|
LLIntegerType* DtoSize_t()
|
||||||
{
|
{
|
||||||
// the type of size_t does not change once set
|
// the type of size_t does not change once set
|
||||||
|
@ -686,9 +654,9 @@ LLConstant* DtoConstFP(Type* t, longdouble value)
|
||||||
#else
|
#else
|
||||||
return LLConstantFP::get(gIR->context(), APFloat(APInt(128, 2, bits)));
|
return LLConstantFP::get(gIR->context(), APFloat(APInt(128, 2, bits)));
|
||||||
#endif
|
#endif
|
||||||
} else {
|
|
||||||
assert(0 && "Unknown floating point type encountered");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
llvm_unreachable("Unknown floating point type encountered");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -54,9 +54,6 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym);
|
||||||
LLGlobalValue::LinkageTypes DtoInternalLinkage(Dsymbol* sym);
|
LLGlobalValue::LinkageTypes DtoInternalLinkage(Dsymbol* sym);
|
||||||
LLGlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym);
|
LLGlobalValue::LinkageTypes DtoExternalLinkage(Dsymbol* sym);
|
||||||
|
|
||||||
// TODO: this one should be removed!!!
|
|
||||||
LLValue* DtoPointedType(LLValue* ptr, LLValue* val);
|
|
||||||
|
|
||||||
// some types
|
// some types
|
||||||
LLIntegerType* DtoSize_t();
|
LLIntegerType* DtoSize_t();
|
||||||
LLStructType* DtoInterfaceInfoType();
|
LLStructType* DtoInterfaceInfoType();
|
||||||
|
|
|
@ -787,7 +787,7 @@ void TypeInfoClassDeclaration::codegen(Ir*i)
|
||||||
void TypeInfoClassDeclaration::llvmDefine()
|
void TypeInfoClassDeclaration::llvmDefine()
|
||||||
{
|
{
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
assert(0);
|
llvm_unreachable("TypeInfoClassDeclaration should not be called for D2");
|
||||||
#endif
|
#endif
|
||||||
Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars());
|
Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
|
@ -139,8 +139,7 @@ llvm::Type * IrTypeBasic::basic2llvm(Type* t)
|
||||||
case Tbool:
|
case Tbool:
|
||||||
return llvm::Type::getInt1Ty(ctx);
|
return llvm::Type::getInt1Ty(ctx);
|
||||||
default:
|
default:
|
||||||
assert(0 && "not basic type");
|
llvm_unreachable("Unknown basic type.");
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue