mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
IntegerType is now contextifed.
Requires llvm >= 78969. resistor says this will be the last context API change :)
This commit is contained in:
@@ -102,8 +102,8 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
|
||||
// Lvalue use ('aa[key] = value') auto-adds an element.
|
||||
if (!lvalue && global.params.useArrayBounds) {
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* failbb = llvm::BasicBlock::Create("aaboundscheckfail", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* okbb = llvm::BasicBlock::Create("aaboundsok", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* failbb = llvm::BasicBlock::Create(gIR->context(), "aaboundscheckfail", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* okbb = llvm::BasicBlock::Create(gIR->context(), "aaboundsok", gIR->topfunc(), oldend);
|
||||
|
||||
LLValue* nullaa = LLConstant::getNullValue(ret->getType());
|
||||
LLValue* cond = gIR->ir->CreateICmpNE(nullaa, ret, "aaboundscheck");
|
||||
|
||||
@@ -231,19 +231,19 @@ namespace {
|
||||
switch (cl.classes[0]) {
|
||||
case Integer: {
|
||||
unsigned bits = (size >= 8 ? 64 : (size * 8));
|
||||
parts.push_back(LLIntegerType::get(bits));
|
||||
parts.push_back(LLIntegerType::get(gIR->context(), bits));
|
||||
break;
|
||||
}
|
||||
|
||||
case Sse:
|
||||
parts.push_back(size <= 4 ? LLType::FloatTy : LLType::DoubleTy);
|
||||
parts.push_back(size <= 4 ? LLType::getFloatTy(gIR->context()) : LLType::getDoubleTy(gIR->context()));
|
||||
break;
|
||||
|
||||
case X87:
|
||||
assert(cl.classes[1] == X87Up && "Upper half of real not X87Up?");
|
||||
/// The type only contains a single real/ireal field,
|
||||
/// so just use that type.
|
||||
return const_cast<LLType*>(LLType::X86_FP80Ty);
|
||||
return const_cast<LLType*>(LLType::getX86_FP80Ty(gIR->context()));
|
||||
|
||||
default:
|
||||
assert(0 && "Unanticipated argument class");
|
||||
@@ -260,11 +260,11 @@ namespace {
|
||||
case Integer: {
|
||||
assert(size > 8);
|
||||
unsigned bits = (size - 8) * 8;
|
||||
parts.push_back(LLIntegerType::get(bits));
|
||||
parts.push_back(LLIntegerType::get(gIR->context(), bits));
|
||||
break;
|
||||
}
|
||||
case Sse:
|
||||
parts.push_back(size <= 12 ? LLType::FloatTy : LLType::DoubleTy);
|
||||
parts.push_back(size <= 12 ? LLType::getFloatTy(gIR->context()) : LLType::getDoubleTy(gIR->context()));
|
||||
break;
|
||||
|
||||
case X87Up:
|
||||
@@ -275,7 +275,7 @@ namespace {
|
||||
// I can't find this anywhere in the ABI documentation,
|
||||
// but this is what gcc does (both regular and llvm-gcc).
|
||||
// (This triggers for types like union { real r; byte b; })
|
||||
parts.push_back(LLType::DoubleTy);
|
||||
parts.push_back(LLType::getDoubleTy(gIR->context()));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
28
gen/abi.cpp
28
gen/abi.cpp
@@ -56,13 +56,13 @@ struct X86_cfloat_rewrite : ABIRewrite
|
||||
LLValue* in = dv->getRVal();
|
||||
|
||||
// extract real part
|
||||
LLValue* rpart = gIR->ir->CreateTrunc(in, LLType::Int32Ty);
|
||||
rpart = gIR->ir->CreateBitCast(rpart, LLType::FloatTy, ".re");
|
||||
LLValue* rpart = gIR->ir->CreateTrunc(in, LLType::getInt32Ty(gIR->context()));
|
||||
rpart = gIR->ir->CreateBitCast(rpart, LLType::getFloatTy(gIR->context()), ".re");
|
||||
|
||||
// extract imag part
|
||||
LLValue* ipart = gIR->ir->CreateLShr(in, LLConstantInt::get(LLType::Int64Ty, 32, false));
|
||||
ipart = gIR->ir->CreateTrunc(ipart, LLType::Int32Ty);
|
||||
ipart = gIR->ir->CreateBitCast(ipart, LLType::FloatTy, ".im");
|
||||
LLValue* ipart = gIR->ir->CreateLShr(in, LLConstantInt::get(LLType::getInt64Ty(gIR->context()), 32, false));
|
||||
ipart = gIR->ir->CreateTrunc(ipart, LLType::getInt32Ty(gIR->context()));
|
||||
ipart = gIR->ir->CreateBitCast(ipart, LLType::getFloatTy(gIR->context()), ".im");
|
||||
|
||||
// return {float,float} aggr pair with same bits
|
||||
return DtoAggrPair(rpart, ipart, ".final_cfloat");
|
||||
@@ -76,18 +76,18 @@ struct X86_cfloat_rewrite : ABIRewrite
|
||||
// extract real
|
||||
LLValue* r = gIR->ir->CreateExtractValue(v, 0);
|
||||
// cast to i32
|
||||
r = gIR->ir->CreateBitCast(r, LLType::Int32Ty);
|
||||
r = gIR->ir->CreateBitCast(r, LLType::getInt32Ty(gIR->context()));
|
||||
// zext to i64
|
||||
r = gIR->ir->CreateZExt(r, LLType::Int64Ty);
|
||||
r = gIR->ir->CreateZExt(r, LLType::getInt64Ty(gIR->context()));
|
||||
|
||||
// extract imag
|
||||
LLValue* i = gIR->ir->CreateExtractValue(v, 1);
|
||||
// cast to i32
|
||||
i = gIR->ir->CreateBitCast(i, LLType::Int32Ty);
|
||||
i = gIR->ir->CreateBitCast(i, LLType::getInt32Ty(gIR->context()));
|
||||
// zext to i64
|
||||
i = gIR->ir->CreateZExt(i, LLType::Int64Ty);
|
||||
i = gIR->ir->CreateZExt(i, LLType::getInt64Ty(gIR->context()));
|
||||
// shift up
|
||||
i = gIR->ir->CreateShl(i, LLConstantInt::get(LLType::Int64Ty, 32, false));
|
||||
i = gIR->ir->CreateShl(i, LLConstantInt::get(LLType::getInt64Ty(gIR->context()), 32, false));
|
||||
|
||||
// combine and return
|
||||
return v = gIR->ir->CreateOr(r, i);
|
||||
@@ -96,7 +96,7 @@ struct X86_cfloat_rewrite : ABIRewrite
|
||||
// {float,float} -> i64
|
||||
const LLType* type(Type*, const LLType* t)
|
||||
{
|
||||
return LLType::Int64Ty;
|
||||
return LLType::getInt64Ty(gIR->context());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -131,13 +131,13 @@ struct X86_struct_to_register : ABIRewrite
|
||||
Logger::println("rewriting struct -> int");
|
||||
assert(dv->isLVal());
|
||||
LLValue* mem = dv->getLVal();
|
||||
const LLType* t = LLIntegerType::get(dty->size()*8);
|
||||
const LLType* t = LLIntegerType::get(gIR->context(), dty->size()*8);
|
||||
return DtoLoad(DtoBitCast(mem, getPtrToType(t)));
|
||||
}
|
||||
const LLType* type(Type* t, const LLType*)
|
||||
{
|
||||
size_t sz = t->size()*8;
|
||||
return LLIntegerType::get(sz);
|
||||
return LLIntegerType::get(gIR->context(), sz);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -258,7 +258,7 @@ struct X86TargetABI : TargetABI
|
||||
if (tf->next->toBasetype() == Type::tcomplex32)
|
||||
{
|
||||
fty.ret->rewrite = &cfloatToInt;
|
||||
fty.ret->ltype = LLType::Int64Ty;
|
||||
fty.ret->ltype = LLType::getInt64Ty(gIR->context());
|
||||
}
|
||||
|
||||
// IMPLICIT PARAMETERS
|
||||
|
||||
@@ -24,8 +24,8 @@ const LLStructType* DtoArrayType(Type* arrayTy)
|
||||
{
|
||||
assert(arrayTy->nextOf());
|
||||
const LLType* elemty = DtoType(arrayTy->nextOf());
|
||||
if (elemty == LLType::VoidTy)
|
||||
elemty = LLType::Int8Ty;
|
||||
if (elemty == LLType::getVoidTy(gIR->context()))
|
||||
elemty = LLType::getInt8Ty(gIR->context());
|
||||
return LLStructType::get(gIR->context(), DtoSize_t(), getPtrToType(elemty), NULL);
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ const LLArrayType* DtoStaticArrayType(Type* t)
|
||||
Type* tnext = tsa->nextOf();
|
||||
|
||||
const LLType* elemty = DtoType(tnext);
|
||||
if (elemty == LLType::VoidTy)
|
||||
elemty = LLType::Int8Ty;
|
||||
if (elemty == LLType::getVoidTy(gIR->context()))
|
||||
elemty = LLType::getInt8Ty(gIR->context());
|
||||
|
||||
return LLArrayType::get(elemty, tsa->dim->toUInteger());
|
||||
}
|
||||
@@ -112,7 +112,7 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value)
|
||||
switch (arrayelemty->ty)
|
||||
{
|
||||
case Tbool:
|
||||
val = gIR->ir->CreateZExt(val, LLType::Int8Ty, ".bool");
|
||||
val = gIR->ir->CreateZExt(val, LLType::getInt8Ty(gIR->context()), ".bool");
|
||||
// fall through
|
||||
|
||||
case Tvoid:
|
||||
@@ -713,10 +713,10 @@ static LLValue* DtoArrayEqCmp_impl(Loc& loc, const char* func, DValue* l, DValue
|
||||
LLSmallVector<LLValue*, 3> args;
|
||||
|
||||
// get values, reinterpret cast to void[]
|
||||
lmem = DtoAggrPaint(l->getRVal(), DtoArrayType(LLType::Int8Ty));
|
||||
lmem = DtoAggrPaint(l->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context())));
|
||||
args.push_back(lmem);
|
||||
|
||||
rmem = DtoAggrPaint(r->getRVal(), DtoArrayType(LLType::Int8Ty));
|
||||
rmem = DtoAggrPaint(r->getRVal(), DtoArrayType(LLType::getInt8Ty(gIR->context())));
|
||||
args.push_back(rmem);
|
||||
|
||||
// pass array typeinfo ?
|
||||
@@ -1040,8 +1040,8 @@ void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, bool isslice)
|
||||
// runtime check
|
||||
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* failbb = llvm::BasicBlock::Create("arrayboundscheckfail", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* okbb = llvm::BasicBlock::Create("arrayboundsok", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* failbb = llvm::BasicBlock::Create(gIR->context(), "arrayboundscheckfail", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* okbb = llvm::BasicBlock::Create(gIR->context(), "arrayboundsok", gIR->topfunc(), oldend);
|
||||
|
||||
llvm::ICmpInst::Predicate cmpop = isslice ? llvm::ICmpInst::ICMP_ULE : llvm::ICmpInst::ICMP_ULT;
|
||||
LLValue* cond = gIR->ir->CreateICmp(cmpop, index->getRVal(), DtoArrayLen(arr), "boundscheck");
|
||||
|
||||
@@ -703,7 +703,7 @@ void AsmBlockStatement::toIR(IRState* p)
|
||||
if (asmblock->retn)
|
||||
retty = asmblock->retty;
|
||||
else
|
||||
retty = llvm::Type::VoidTy;
|
||||
retty = llvm::Type::getVoidTy(gIR->context());
|
||||
|
||||
// build argument types
|
||||
std::vector<const LLType*> types;
|
||||
@@ -732,7 +732,7 @@ void AsmBlockStatement::toIR(IRState* p)
|
||||
llvm::InlineAsm* ia = llvm::InlineAsm::get(fty, code, out_c, true);
|
||||
|
||||
llvm::CallInst* call = p->ir->CreateCall(ia, args.begin(), args.end(),
|
||||
retty == LLType::VoidTy ? "" : "asm");
|
||||
retty == LLType::getVoidTy(gIR->context()) ? "" : "asm");
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "Complete asm statement: " << *call << '\n';
|
||||
@@ -759,7 +759,7 @@ void AsmBlockStatement::toIR(IRState* p)
|
||||
|
||||
// make new blocks
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterasmgotoforwarder", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "afterasmgotoforwarder", p->topfunc(), oldend);
|
||||
|
||||
llvm::LoadInst* val = p->ir->CreateLoad(jump_target, "__llvm_jump_target_value");
|
||||
llvm::SwitchInst* sw = p->ir->CreateSwitch(val, bb, gotoToVal.size());
|
||||
@@ -768,8 +768,8 @@ void AsmBlockStatement::toIR(IRState* p)
|
||||
std::map<Identifier*, int>::iterator it, end = gotoToVal.end();
|
||||
for(it = gotoToVal.begin(); it != end; ++it)
|
||||
{
|
||||
llvm::BasicBlock* casebb = llvm::BasicBlock::Create("case", p->topfunc(), bb);
|
||||
sw->addCase(LLConstantInt::get(llvm::IntegerType::get(32), it->second), casebb);
|
||||
llvm::BasicBlock* casebb = llvm::BasicBlock::Create(gIR->context(), "case", p->topfunc(), bb);
|
||||
sw->addCase(LLConstantInt::get(llvm::IntegerType::get(gIR->context(), 32), it->second), casebb);
|
||||
|
||||
p->scope() = IRScope(casebb,bb);
|
||||
DtoGoto(loc, it->first, enclosingFinally);
|
||||
|
||||
@@ -630,7 +630,7 @@ static LLConstant* build_class_dtor(ClassDeclaration* cd)
|
||||
return getNullPtr(getVoidPtrType());
|
||||
|
||||
dtor->codegen(Type::sir);
|
||||
return llvm::ConstantExpr::getBitCast(dtor->ir.irFunc->func, getPtrToType(LLType::Int8Ty));
|
||||
return llvm::ConstantExpr::getBitCast(dtor->ir.irFunc->func, getPtrToType(LLType::getInt8Ty(gIR->context())));
|
||||
}
|
||||
|
||||
static unsigned build_classinfo_flags(ClassDeclaration* cd)
|
||||
|
||||
@@ -24,16 +24,16 @@ const LLType* DtoComplexBaseType(Type* t)
|
||||
TY ty = t->toBasetype()->ty;
|
||||
const LLType* base;
|
||||
if (ty == Tcomplex32) {
|
||||
return LLType::FloatTy;
|
||||
return LLType::getFloatTy(gIR->context());
|
||||
}
|
||||
else if (ty == Tcomplex64) {
|
||||
return LLType::DoubleTy;
|
||||
return LLType::getDoubleTy(gIR->context());
|
||||
}
|
||||
else if (ty == Tcomplex80) {
|
||||
if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64))
|
||||
return LLType::X86_FP80Ty;
|
||||
return LLType::getX86_FP80Ty(gIR->context());
|
||||
else
|
||||
return LLType::DoubleTy;
|
||||
return LLType::getDoubleTy(gIR->context());
|
||||
}
|
||||
else {
|
||||
assert(0);
|
||||
|
||||
@@ -21,36 +21,36 @@ void RegisterDwarfSymbols(llvm::Module* mod) {
|
||||
using namespace llvm;
|
||||
// Type Definitions
|
||||
std::vector<const Type*>StructTy_llvm_dbg_anchor_type_fields;
|
||||
StructTy_llvm_dbg_anchor_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_anchor_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_anchor_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_anchor_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructType* StructTy_llvm_dbg_anchor_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_anchor_type_fields, /*isPacked=*/false);
|
||||
mod->addTypeName("llvm.dbg.anchor.type", StructTy_llvm_dbg_anchor_type);
|
||||
|
||||
std::vector<const Type*>StructTy_llvm_dbg_basictype_type_fields;
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
std::vector<const Type*>StructTy_1_fields;
|
||||
StructType* StructTy_1 = StructType::get(mod->getContext(), StructTy_1_fields, /*isPacked=*/false);
|
||||
|
||||
PointerType* PointerTy_0 = PointerType::get(StructTy_1,0);
|
||||
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(PointerTy_0);
|
||||
PointerType* PointerTy_2 = PointerType::get(IntegerType::get(8),0);
|
||||
PointerType* PointerTy_2 = PointerType::get(IntegerType::get(mod->getContext(), 8),0);
|
||||
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(64));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(64));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(64));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(mod->getContext(), 64));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(mod->getContext(), 64));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(mod->getContext(), 64));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_basictype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructType* StructTy_llvm_dbg_basictype_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_basictype_type_fields, /*isPacked=*/false);
|
||||
mod->addTypeName("llvm.dbg.basictype.type", StructTy_llvm_dbg_basictype_type);
|
||||
|
||||
std::vector<const Type*>StructTy_llvm_dbg_compile_unit_type_fields;
|
||||
StructTy_llvm_dbg_compile_unit_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_compile_unit_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_compile_unit_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_compile_unit_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_compile_unit_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_compile_unit_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_compile_unit_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_compile_unit_type_fields.push_back(PointerTy_2);
|
||||
@@ -58,71 +58,71 @@ void RegisterDwarfSymbols(llvm::Module* mod) {
|
||||
mod->addTypeName("llvm.dbg.compile_unit.type", StructTy_llvm_dbg_compile_unit_type);
|
||||
|
||||
std::vector<const Type*>StructTy_llvm_dbg_compositetype_type_fields;
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(64));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(64));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(64));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(mod->getContext(), 64));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(mod->getContext(), 64));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(mod->getContext(), 64));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_compositetype_type_fields.push_back(PointerTy_0);
|
||||
StructType* StructTy_llvm_dbg_compositetype_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_compositetype_type_fields, /*isPacked=*/false);
|
||||
mod->addTypeName("llvm.dbg.compositetype.type", StructTy_llvm_dbg_compositetype_type);
|
||||
|
||||
std::vector<const Type*>StructTy_llvm_dbg_derivedtype_type_fields;
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(64));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(64));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(64));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(mod->getContext(), 64));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(mod->getContext(), 64));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(mod->getContext(), 64));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_derivedtype_type_fields.push_back(PointerTy_0);
|
||||
StructType* StructTy_llvm_dbg_derivedtype_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_derivedtype_type_fields, /*isPacked=*/false);
|
||||
mod->addTypeName("llvm.dbg.derivedtype.type", StructTy_llvm_dbg_derivedtype_type);
|
||||
|
||||
std::vector<const Type*>StructTy_llvm_dbg_global_variable_type_fields;
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(1));
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(1));
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(mod->getContext(), 1));
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(IntegerType::get(mod->getContext(), 1));
|
||||
StructTy_llvm_dbg_global_variable_type_fields.push_back(PointerTy_0);
|
||||
StructType* StructTy_llvm_dbg_global_variable_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_global_variable_type_fields, /*isPacked=*/false);
|
||||
mod->addTypeName("llvm.dbg.global_variable.type", StructTy_llvm_dbg_global_variable_type);
|
||||
|
||||
std::vector<const Type*>StructTy_llvm_dbg_subprogram_type_fields;
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(1));
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(1));
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(mod->getContext(), 1));
|
||||
StructTy_llvm_dbg_subprogram_type_fields.push_back(IntegerType::get(mod->getContext(), 1));
|
||||
StructType* StructTy_llvm_dbg_subprogram_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_subprogram_type_fields, /*isPacked=*/false);
|
||||
mod->addTypeName("llvm.dbg.subprogram.type", StructTy_llvm_dbg_subprogram_type);
|
||||
|
||||
std::vector<const Type*>StructTy_llvm_dbg_variable_type_fields;
|
||||
StructTy_llvm_dbg_variable_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_variable_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_variable_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_variable_type_fields.push_back(PointerTy_2);
|
||||
StructTy_llvm_dbg_variable_type_fields.push_back(PointerTy_0);
|
||||
StructTy_llvm_dbg_variable_type_fields.push_back(IntegerType::get(32));
|
||||
StructTy_llvm_dbg_variable_type_fields.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
StructTy_llvm_dbg_variable_type_fields.push_back(PointerTy_0);
|
||||
StructType* StructTy_llvm_dbg_variable_type = StructType::get(mod->getContext(), StructTy_llvm_dbg_variable_type_fields, /*isPacked=*/false);
|
||||
mod->addTypeName("llvm.dbg.variable.type", StructTy_llvm_dbg_variable_type);
|
||||
@@ -130,16 +130,16 @@ void RegisterDwarfSymbols(llvm::Module* mod) {
|
||||
std::vector<const Type*>FuncTy_3_args;
|
||||
FuncTy_3_args.push_back(PointerTy_0);
|
||||
FunctionType* FuncTy_3 = FunctionType::get(
|
||||
/*Result=*/Type::VoidTy,
|
||||
/*Result=*/Type::getVoidTy(mod->getContext()),
|
||||
/*Params=*/FuncTy_3_args,
|
||||
/*isVarArg=*/false);
|
||||
|
||||
std::vector<const Type*>FuncTy_4_args;
|
||||
FuncTy_4_args.push_back(IntegerType::get(32));
|
||||
FuncTy_4_args.push_back(IntegerType::get(32));
|
||||
FuncTy_4_args.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
FuncTy_4_args.push_back(IntegerType::get(mod->getContext(), 32));
|
||||
FuncTy_4_args.push_back(PointerTy_0);
|
||||
FunctionType* FuncTy_4 = FunctionType::get(
|
||||
/*Result=*/Type::VoidTy,
|
||||
/*Result=*/Type::getVoidTy(mod->getContext()),
|
||||
/*Params=*/FuncTy_4_args,
|
||||
/*isVarArg=*/false);
|
||||
|
||||
@@ -147,7 +147,7 @@ void RegisterDwarfSymbols(llvm::Module* mod) {
|
||||
FuncTy_5_args.push_back(PointerTy_0);
|
||||
FuncTy_5_args.push_back(PointerTy_0);
|
||||
FunctionType* FuncTy_5 = FunctionType::get(
|
||||
/*Result=*/Type::VoidTy,
|
||||
/*Result=*/Type::getVoidTy(mod->getContext()),
|
||||
/*Params=*/FuncTy_5_args,
|
||||
/*isVarArg=*/false);
|
||||
|
||||
|
||||
@@ -631,15 +631,15 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
||||
|
||||
std::string entryname("entry");
|
||||
|
||||
llvm::BasicBlock* beginbb = llvm::BasicBlock::Create(entryname,func);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endentry",func);
|
||||
llvm::BasicBlock* beginbb = llvm::BasicBlock::Create(gIR->context(), entryname,func);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endentry",func);
|
||||
|
||||
//assert(gIR->scopes.empty());
|
||||
gIR->scopes.push_back(IRScope(beginbb, endbb));
|
||||
|
||||
// create alloca point
|
||||
// this gets erased when the function is complete, so alignment etc does not matter at all
|
||||
llvm::Instruction* allocaPoint = new llvm::AllocaInst(LLType::Int32Ty, "alloca point", beginbb);
|
||||
llvm::Instruction* allocaPoint = new llvm::AllocaInst(LLType::getInt32Ty(gIR->context()), "alloca point", beginbb);
|
||||
irfunction->allocapoint = allocaPoint;
|
||||
|
||||
// debug info - after all allocas, but before any llvm.dbg.declare etc
|
||||
@@ -797,21 +797,21 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
||||
|
||||
// pass the previous block into this block
|
||||
if (global.params.symdebug) DtoDwarfFuncEnd(fd);
|
||||
if (func->getReturnType() == LLType::VoidTy) {
|
||||
llvm::ReturnInst::Create(gIR->scopebb());
|
||||
if (func->getReturnType() == LLType::getVoidTy(gIR->context())) {
|
||||
llvm::ReturnInst::Create(gIR->context(), gIR->scopebb());
|
||||
}
|
||||
else if (!fd->isMain()) {
|
||||
AsmBlockStatement* asmb = fd->fbody->endsWithAsm();
|
||||
if (asmb) {
|
||||
assert(asmb->abiret);
|
||||
llvm::ReturnInst::Create(asmb->abiret, bb);
|
||||
llvm::ReturnInst::Create(gIR->context(), asmb->abiret, bb);
|
||||
}
|
||||
else {
|
||||
llvm::ReturnInst::Create(llvm::UndefValue::get(func->getReturnType()), bb);
|
||||
llvm::ReturnInst::Create(gIR->context(), llvm::UndefValue::get(func->getReturnType()), bb);
|
||||
}
|
||||
}
|
||||
else
|
||||
llvm::ReturnInst::Create(LLConstant::getNullValue(func->getReturnType()), bb);
|
||||
llvm::ReturnInst::Create(gIR->context(), LLConstant::getNullValue(func->getReturnType()), bb);
|
||||
}
|
||||
|
||||
// std::cout << *func << std::endl;
|
||||
|
||||
@@ -200,7 +200,7 @@ llvm::CallSite IRState::CreateCallOrInvoke(LLValue* Callee, InputIterator ArgBeg
|
||||
return call;
|
||||
}
|
||||
|
||||
llvm::BasicBlock* postinvoke = llvm::BasicBlock::Create("postinvoke", topfunc(), scopeend());
|
||||
llvm::BasicBlock* postinvoke = llvm::BasicBlock::Create(gIR->context(), "postinvoke", topfunc(), scopeend());
|
||||
llvm::InvokeInst* invoke = ir->CreateInvoke(Callee, postinvoke, pad, ArgBegin, ArgEnd, Name);
|
||||
if (LLFunction* fn = llvm::dyn_cast<LLFunction>(Callee))
|
||||
invoke->setAttributes(fn->getAttributes());
|
||||
|
||||
@@ -213,7 +213,7 @@ void DtoGoto(Loc loc, Identifier* target, TryFinallyStatement* sourceFinally)
|
||||
std::string labelname = gIR->func()->gen->getScopedLabelName(target->toChars());
|
||||
llvm::BasicBlock*& targetBB = gIR->func()->gen->labelToBB[labelname];
|
||||
if (targetBB == NULL)
|
||||
targetBB = llvm::BasicBlock::Create("label_" + labelname, gIR->topfunc());
|
||||
targetBB = llvm::BasicBlock::Create(gIR->context(), "label_" + labelname, gIR->topfunc());
|
||||
|
||||
// emit code for finallys between goto and label
|
||||
DtoEnclosingHandlers(loc, lblstmt);
|
||||
|
||||
@@ -233,11 +233,11 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl)
|
||||
} else if (rt->ty == Tcomplex32) {
|
||||
// extern(C) cfloat is return as i64
|
||||
as->out_c = "=A,";
|
||||
asmblock->retty = LLType::Int64Ty;
|
||||
asmblock->retty = LLType::getInt64Ty(gIR->context());
|
||||
} else {
|
||||
// cdouble and creal extern(C) are returned in pointer
|
||||
// don't add anything!
|
||||
asmblock->retty = LLType::VoidTy;
|
||||
asmblock->retty = LLType::getVoidTy(gIR->context());
|
||||
asmblock->retn = 0;
|
||||
return;
|
||||
}
|
||||
@@ -314,7 +314,7 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl)
|
||||
// For compatibility, use the GCC/LLVM-GCC way for extern(C/Windows)
|
||||
// extern(C) cfloat -> %xmm0 (extract two floats)
|
||||
as->out_c = "={xmm0},";
|
||||
asmblock->retty = LLType::DoubleTy;
|
||||
asmblock->retty = LLType::getDoubleTy(gIR->context());
|
||||
} else if (rt->iscomplex()) {
|
||||
// cdouble and extern(D) cfloat -> re=%xmm0, im=%xmm1
|
||||
as->out_c = "={xmm0},={xmm1},";
|
||||
|
||||
@@ -62,13 +62,13 @@ namespace {
|
||||
|
||||
void EmitMemSet(IRBuilder<>& B, Value* Dst, Value* Val, Value* Len,
|
||||
const Analysis& A) {
|
||||
Dst = B.CreateBitCast(Dst, PointerType::getUnqual(Type::Int8Ty));
|
||||
Dst = B.CreateBitCast(Dst, PointerType::getUnqual(B.getInt8Ty()));
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
const Type* Tys[1];
|
||||
Tys[0] = Len->getType();
|
||||
Function *MemSet = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 1);
|
||||
Value *Align = ConstantInt::get(Type::Int32Ty, 1);
|
||||
Value *Align = ConstantInt::get(B.getInt32Ty(), 1);
|
||||
|
||||
CallSite CS = B.CreateCall4(MemSet, Dst, Val, Len, Align);
|
||||
if (A.CGNode)
|
||||
@@ -77,7 +77,7 @@ void EmitMemSet(IRBuilder<>& B, Value* Dst, Value* Val, Value* Len,
|
||||
|
||||
static void EmitMemZero(IRBuilder<>& B, Value* Dst, Value* Len,
|
||||
const Analysis& A) {
|
||||
EmitMemSet(B, Dst, ConstantInt::get(Type::Int8Ty, 0), Len, A);
|
||||
EmitMemSet(B, Dst, ConstantInt::get(B.getInt8Ty(), 0), Len, A);
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace {
|
||||
}
|
||||
|
||||
// Convert array size to 32 bits if necessary
|
||||
Value* count = Builder.CreateIntCast(arrSize, Type::Int32Ty, false);
|
||||
Value* count = Builder.CreateIntCast(arrSize, Builder.getInt32Ty(), false);
|
||||
AllocaInst* alloca = Builder.CreateAlloca(Ty, count, ".nongc_mem"); // FIXME: align?
|
||||
|
||||
if (Initialized) {
|
||||
@@ -587,7 +587,7 @@ bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT) {
|
||||
// its return value and doesn't unwind (a readonly function can leak bits
|
||||
// by throwing an exception or not depending on the input value).
|
||||
if (CS.onlyReadsMemory() && CS.doesNotThrow() &&
|
||||
I->getType() == Type::VoidTy)
|
||||
I->getType() == Type::getVoidTy(I->getContext()))
|
||||
break;
|
||||
|
||||
// Not captured if only passed via 'nocapture' arguments. Note that
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace {
|
||||
|
||||
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
|
||||
Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
|
||||
return B.CreateBitCast(V, PointerType::getUnqual(Type::Int8Ty), "cstr");
|
||||
return B.CreateBitCast(V, PointerType::getUnqual(B.getInt8Ty()), "cstr");
|
||||
}
|
||||
|
||||
/// EmitMemCpy - Emit a call to the memcpy function to the builder. This always
|
||||
@@ -95,7 +95,7 @@ Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
|
||||
Tys[0] = Len->getType();
|
||||
Value *MemCpy = Intrinsic::getDeclaration(M, IID, Tys, 1);
|
||||
return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src, B), Len,
|
||||
ConstantInt::get(Type::Int32Ty, Align));
|
||||
ConstantInt::get(B.getInt32Ty(), Align));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -202,7 +202,7 @@ struct VISIBILITY_HIDDEN AllocationOpt : public LibCallOptimization {
|
||||
Constant* C = 0;
|
||||
if ((C = dyn_cast<Constant>(Cmp->getOperand(0)))
|
||||
|| (C = dyn_cast<Constant>(Cmp->getOperand(1)))) {
|
||||
Value* Result = ConstantInt::get(Type::Int1Ty, !Cmp->isTrueWhenEqual());
|
||||
Value* Result = ConstantInt::get(B.getInt1Ty(), !Cmp->isTrueWhenEqual());
|
||||
Cmp->replaceAllUsesWith(Result);
|
||||
// Don't delete the comparison because there may be an
|
||||
// iterator to it. Instead, set the operands to constants
|
||||
@@ -228,8 +228,8 @@ struct VISIBILITY_HIDDEN ArraySliceCopyOpt : public LibCallOptimization {
|
||||
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
|
||||
// Verify we have a reasonable prototype for _d_array_slice_copy
|
||||
const FunctionType *FT = Callee->getFunctionType();
|
||||
const Type* VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
|
||||
if (Callee->arg_size() != 4 || FT->getReturnType() != Type::VoidTy ||
|
||||
const Type* VoidPtrTy = PointerType::getUnqual(B.getInt8Ty());
|
||||
if (Callee->arg_size() != 4 || FT->getReturnType() != B.getVoidTy() ||
|
||||
FT->getParamType(0) != VoidPtrTy ||
|
||||
!isa<IntegerType>(FT->getParamType(1)) ||
|
||||
FT->getParamType(2) != VoidPtrTy ||
|
||||
|
||||
@@ -130,20 +130,20 @@ static const LLType* rt_array(const LLType* elemty)
|
||||
static const LLType* rt_dg1()
|
||||
{
|
||||
std::vector<const LLType*> types;
|
||||
types.push_back(rt_ptr(LLType::Int8Ty));
|
||||
types.push_back(rt_ptr(LLType::Int8Ty));
|
||||
const llvm::FunctionType* fty = llvm::FunctionType::get(LLType::Int32Ty, types, false);
|
||||
return llvm::StructType::get(gIR->context(), rt_ptr(LLType::Int8Ty), rt_ptr(fty), NULL);
|
||||
types.push_back(rt_ptr(LLType::getInt8Ty(gIR->context())));
|
||||
types.push_back(rt_ptr(LLType::getInt8Ty(gIR->context())));
|
||||
const llvm::FunctionType* fty = llvm::FunctionType::get(LLType::getInt32Ty(gIR->context()), types, false);
|
||||
return llvm::StructType::get(gIR->context(), rt_ptr(LLType::getInt8Ty(gIR->context())), rt_ptr(fty), NULL);
|
||||
}
|
||||
|
||||
static const LLType* rt_dg2()
|
||||
{
|
||||
std::vector<const LLType*> types;
|
||||
types.push_back(rt_ptr(LLType::Int8Ty));
|
||||
types.push_back(rt_ptr(LLType::Int8Ty));
|
||||
types.push_back(rt_ptr(LLType::Int8Ty));
|
||||
const llvm::FunctionType* fty = llvm::FunctionType::get(LLType::Int32Ty, types, false);
|
||||
return llvm::StructType::get(gIR->context(), rt_ptr(LLType::Int8Ty), rt_ptr(fty), NULL);
|
||||
types.push_back(rt_ptr(LLType::getInt8Ty(gIR->context())));
|
||||
types.push_back(rt_ptr(LLType::getInt8Ty(gIR->context())));
|
||||
types.push_back(rt_ptr(LLType::getInt8Ty(gIR->context())));
|
||||
const llvm::FunctionType* fty = llvm::FunctionType::get(LLType::getInt32Ty(gIR->context()), types, false);
|
||||
return llvm::StructType::get(gIR->context(), rt_ptr(LLType::getInt8Ty(gIR->context())), rt_ptr(fty), NULL);
|
||||
}
|
||||
|
||||
static void LLVM_D_BuildRuntimeModule()
|
||||
@@ -152,22 +152,22 @@ static void LLVM_D_BuildRuntimeModule()
|
||||
M = new llvm::Module("ldc internal runtime", gIR->context());
|
||||
|
||||
Logger::println("building basic types");
|
||||
const LLType* voidTy = LLType::VoidTy;
|
||||
const LLType* boolTy = LLType::Int1Ty;
|
||||
const LLType* byteTy = LLType::Int8Ty;
|
||||
const LLType* shortTy = LLType::Int16Ty;
|
||||
const LLType* intTy = LLType::Int32Ty;
|
||||
const LLType* longTy = LLType::Int64Ty;
|
||||
const LLType* voidTy = LLType::getVoidTy(gIR->context());
|
||||
const LLType* boolTy = LLType::getInt1Ty(gIR->context());
|
||||
const LLType* byteTy = LLType::getInt8Ty(gIR->context());
|
||||
const LLType* shortTy = LLType::getInt16Ty(gIR->context());
|
||||
const LLType* intTy = LLType::getInt32Ty(gIR->context());
|
||||
const LLType* longTy = LLType::getInt64Ty(gIR->context());
|
||||
const LLType* sizeTy = DtoSize_t();
|
||||
|
||||
Logger::println("building float types");
|
||||
const LLType* floatTy = LLType::FloatTy;
|
||||
const LLType* doubleTy = LLType::DoubleTy;
|
||||
const LLType* floatTy = LLType::getFloatTy(gIR->context());
|
||||
const LLType* doubleTy = LLType::getDoubleTy(gIR->context());
|
||||
const LLType* realTy;
|
||||
if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64))
|
||||
realTy = LLType::X86_FP80Ty;
|
||||
realTy = LLType::getX86_FP80Ty(gIR->context());
|
||||
else
|
||||
realTy = LLType::DoubleTy;
|
||||
realTy = LLType::getDoubleTy(gIR->context());
|
||||
|
||||
const LLType* cfloatTy = llvm::StructType::get(gIR->context(), floatTy, floatTy, NULL);
|
||||
const LLType* cdoubleTy = llvm::StructType::get(gIR->context(), doubleTy, doubleTy, NULL);
|
||||
@@ -185,7 +185,7 @@ static void LLVM_D_BuildRuntimeModule()
|
||||
const LLType* typeInfoTy = DtoType(Type::typeinfo->type);
|
||||
|
||||
Logger::println("building aa type");
|
||||
const LLType* aaTy = rt_ptr(llvm::OpaqueType::get());
|
||||
const LLType* aaTy = rt_ptr(llvm::OpaqueType::get(gIR->context()));
|
||||
|
||||
Logger::println("building functions");
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ void ReturnStatement::toIR(IRState* p)
|
||||
{
|
||||
// if the functions return type is void this means that
|
||||
// we are returning through a pointer argument
|
||||
if (p->topfunc()->getReturnType() == LLType::VoidTy)
|
||||
if (p->topfunc()->getReturnType() == LLType::getVoidTy(gIR->context()))
|
||||
{
|
||||
// sanity check
|
||||
IrFunction* f = p->func();
|
||||
@@ -82,7 +82,7 @@ void ReturnStatement::toIR(IRState* p)
|
||||
if (global.params.symdebug) DtoDwarfFuncEnd(f->decl);
|
||||
|
||||
// emit ret
|
||||
llvm::ReturnInst::Create(p->scopebb());
|
||||
llvm::ReturnInst::Create(gIR->context(), p->scopebb());
|
||||
|
||||
}
|
||||
// the return type is not void, so this is a normal "register" return
|
||||
@@ -123,22 +123,22 @@ void ReturnStatement::toIR(IRState* p)
|
||||
DtoEnclosingHandlers(loc, NULL);
|
||||
|
||||
if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);
|
||||
llvm::ReturnInst::Create(v, p->scopebb());
|
||||
llvm::ReturnInst::Create(gIR->context(), v, p->scopebb());
|
||||
}
|
||||
}
|
||||
// no return value expression means it's a void function
|
||||
else
|
||||
{
|
||||
assert(p->topfunc()->getReturnType() == LLType::VoidTy);
|
||||
assert(p->topfunc()->getReturnType() == LLType::getVoidTy(gIR->context()));
|
||||
DtoEnclosingHandlers(loc, NULL);
|
||||
|
||||
if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);
|
||||
llvm::ReturnInst::Create(p->scopebb());
|
||||
llvm::ReturnInst::Create(gIR->context(), p->scopebb());
|
||||
}
|
||||
|
||||
// the return terminated this basicblock, start a new one
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterreturn", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "afterreturn", p->topfunc(), oldend);
|
||||
p->scope() = IRScope(bb,oldend);
|
||||
}
|
||||
|
||||
@@ -189,11 +189,11 @@ void IfStatement::toIR(IRState* p)
|
||||
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
|
||||
llvm::BasicBlock* ifbb = llvm::BasicBlock::Create("if", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endif", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb;
|
||||
llvm::BasicBlock* ifbb = llvm::BasicBlock::Create(gIR->context(), "if", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endif", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create(gIR->context(), "else", gIR->topfunc(), endbb) : endbb;
|
||||
|
||||
if (cond_val->getType() != LLType::Int1Ty) {
|
||||
if (cond_val->getType() != LLType::getInt1Ty(gIR->context())) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "if conditional: " << *cond_val << '\n';
|
||||
cond_val = DtoCast(loc, cond_e, Type::tbool)->getRVal();
|
||||
@@ -240,12 +240,12 @@ void ScopeStatement::toIR(IRState* p)
|
||||
beginbb = bb;
|
||||
}
|
||||
else {
|
||||
beginbb = llvm::BasicBlock::Create("scope", p->topfunc(), oldend);
|
||||
beginbb = llvm::BasicBlock::Create(gIR->context(), "scope", p->topfunc(), oldend);
|
||||
if (!p->scopereturned())
|
||||
llvm::BranchInst::Create(beginbb, bb);
|
||||
}
|
||||
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endscope", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endscope", p->topfunc(), oldend);
|
||||
if (beginbb != bb)
|
||||
p->scope() = IRScope(beginbb, endbb);
|
||||
else
|
||||
@@ -271,9 +271,9 @@ void WhileStatement::toIR(IRState* p)
|
||||
|
||||
// create while blocks
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* whilebb = llvm::BasicBlock::Create("whilecond", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* whilebodybb = llvm::BasicBlock::Create("whilebody", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endwhile", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* whilebb = llvm::BasicBlock::Create(gIR->context(), "whilecond", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* whilebodybb = llvm::BasicBlock::Create(gIR->context(), "whilebody", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endwhile", gIR->topfunc(), oldend);
|
||||
|
||||
// move into the while block
|
||||
p->ir->CreateBr(whilebb);
|
||||
@@ -318,9 +318,9 @@ void DoStatement::toIR(IRState* p)
|
||||
|
||||
// create while blocks
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* dowhilebb = llvm::BasicBlock::Create("dowhile", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* condbb = llvm::BasicBlock::Create("dowhilecond", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("enddowhile", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* dowhilebb = llvm::BasicBlock::Create(gIR->context(), "dowhile", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* condbb = llvm::BasicBlock::Create(gIR->context(), "dowhilecond", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "enddowhile", gIR->topfunc(), oldend);
|
||||
|
||||
// move into the while block
|
||||
assert(!gIR->scopereturned());
|
||||
@@ -362,10 +362,10 @@ void ForStatement::toIR(IRState* p)
|
||||
|
||||
// create for blocks
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* forbb = llvm::BasicBlock::Create("forcond", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* forbodybb = llvm::BasicBlock::Create("forbody", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* forincbb = llvm::BasicBlock::Create("forinc", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endfor", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* forbb = llvm::BasicBlock::Create(gIR->context(), "forcond", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* forbodybb = llvm::BasicBlock::Create(gIR->context(), "forbody", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* forincbb = llvm::BasicBlock::Create(gIR->context(), "forinc", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endfor", gIR->topfunc(), oldend);
|
||||
|
||||
// init
|
||||
if (init != 0)
|
||||
@@ -480,7 +480,7 @@ void BreakStatement::toIR(IRState* p)
|
||||
|
||||
// the break terminated this basicblock, start a new one
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterbreak", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "afterbreak", p->topfunc(), oldend);
|
||||
p->scope() = IRScope(bb,oldend);
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ void ContinueStatement::toIR(IRState* p)
|
||||
|
||||
// the continue terminated this basicblock, start a new one
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftercontinue", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftercontinue", p->topfunc(), oldend);
|
||||
p->scope() = IRScope(bb,oldend);
|
||||
}
|
||||
|
||||
@@ -574,11 +574,11 @@ void TryFinallyStatement::toIR(IRState* p)
|
||||
// create basic blocks
|
||||
llvm::BasicBlock* oldend = p->scopeend();
|
||||
|
||||
llvm::BasicBlock* trybb = llvm::BasicBlock::Create("try", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* finallybb = llvm::BasicBlock::Create("finally", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* trybb = llvm::BasicBlock::Create(gIR->context(), "try", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* finallybb = llvm::BasicBlock::Create(gIR->context(), "finally", p->topfunc(), oldend);
|
||||
// the landing pad for statements in the try block
|
||||
llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create("landingpad", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endtryfinally", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create(gIR->context(), "landingpad", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endtryfinally", p->topfunc(), oldend);
|
||||
|
||||
// pass the previous BB into this
|
||||
assert(!gIR->scopereturned());
|
||||
@@ -641,10 +641,10 @@ void TryCatchStatement::toIR(IRState* p)
|
||||
// create basic blocks
|
||||
llvm::BasicBlock* oldend = p->scopeend();
|
||||
|
||||
llvm::BasicBlock* trybb = llvm::BasicBlock::Create("try", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* trybb = llvm::BasicBlock::Create(gIR->context(), "try", p->topfunc(), oldend);
|
||||
// the landing pad will be responsible for branching to the correct catch block
|
||||
llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create("landingpad", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endtrycatch", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create(gIR->context(), "landingpad", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "endtrycatch", p->topfunc(), oldend);
|
||||
|
||||
// pass the previous BB into this
|
||||
assert(!gIR->scopereturned());
|
||||
@@ -708,7 +708,7 @@ void ThrowStatement::toIR(IRState* p)
|
||||
|
||||
// need a block after the throw for now
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterthrow", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "afterthrow", p->topfunc(), oldend);
|
||||
p->scope() = IRScope(bb,oldend);
|
||||
}
|
||||
|
||||
@@ -833,18 +833,18 @@ void SwitchStatement::toIR(IRState* p)
|
||||
}
|
||||
|
||||
// body block
|
||||
llvm::BasicBlock* bodybb = llvm::BasicBlock::Create("switchbody", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bodybb = llvm::BasicBlock::Create(gIR->context(), "switchbody", p->topfunc(), oldend);
|
||||
|
||||
// default
|
||||
llvm::BasicBlock* defbb = 0;
|
||||
if (sdefault) {
|
||||
Logger::println("has default");
|
||||
defbb = llvm::BasicBlock::Create("default", p->topfunc(), oldend);
|
||||
defbb = llvm::BasicBlock::Create(gIR->context(), "default", p->topfunc(), oldend);
|
||||
sdefault->bodyBB = defbb;
|
||||
}
|
||||
|
||||
// end (break point)
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("switchend", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "switchend", p->topfunc(), oldend);
|
||||
|
||||
// condition var
|
||||
LLValue* condVal;
|
||||
@@ -886,7 +886,7 @@ void CaseStatement::toIR(IRState* p)
|
||||
Logger::println("CaseStatement::toIR(): %s", loc.toChars());
|
||||
LOG_SCOPE;
|
||||
|
||||
llvm::BasicBlock* nbb = llvm::BasicBlock::Create("case", p->topfunc(), p->scopeend());
|
||||
llvm::BasicBlock* nbb = llvm::BasicBlock::Create(gIR->context(), "case", p->topfunc(), p->scopeend());
|
||||
|
||||
if (bodyBB && !bodyBB->getTerminator())
|
||||
{
|
||||
@@ -916,7 +916,7 @@ void DefaultStatement::toIR(IRState* p)
|
||||
|
||||
assert(bodyBB);
|
||||
|
||||
llvm::BasicBlock* nbb = llvm::BasicBlock::Create("default", p->topfunc(), p->scopeend());
|
||||
llvm::BasicBlock* nbb = llvm::BasicBlock::Create(gIR->context(), "default", p->topfunc(), p->scopeend());
|
||||
|
||||
if (!bodyBB->getTerminator())
|
||||
{
|
||||
@@ -958,11 +958,11 @@ void UnrolledLoopStatement::toIR(IRState* p)
|
||||
|
||||
for (size_t i=0; i<nstmt; i++)
|
||||
{
|
||||
blocks[i] = llvm::BasicBlock::Create("unrolledstmt", p->topfunc(), oldend);
|
||||
blocks[i] = llvm::BasicBlock::Create(gIR->context(), "unrolledstmt", p->topfunc(), oldend);
|
||||
}
|
||||
|
||||
// create end block
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("unrolledend", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "unrolledend", p->topfunc(), oldend);
|
||||
|
||||
// enter first stmt
|
||||
if (!p->scopereturned())
|
||||
@@ -1070,10 +1070,10 @@ void ForeachStatement::toIR(IRState* p)
|
||||
}
|
||||
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* condbb = llvm::BasicBlock::Create("foreachcond", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bodybb = llvm::BasicBlock::Create("foreachbody", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* nextbb = llvm::BasicBlock::Create("foreachnext", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("foreachend", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* condbb = llvm::BasicBlock::Create(gIR->context(), "foreachcond", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bodybb = llvm::BasicBlock::Create(gIR->context(), "foreachbody", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* nextbb = llvm::BasicBlock::Create(gIR->context(), "foreachnext", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "foreachend", p->topfunc(), oldend);
|
||||
|
||||
llvm::BranchInst::Create(condbb, p->scopebb());
|
||||
|
||||
@@ -1163,10 +1163,10 @@ void ForeachRangeStatement::toIR(IRState* p)
|
||||
|
||||
// set up the block we'll need
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* condbb = llvm::BasicBlock::Create("foreachrange_cond", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bodybb = llvm::BasicBlock::Create("foreachrange_body", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* nextbb = llvm::BasicBlock::Create("foreachrange_next", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("foreachrange_end", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* condbb = llvm::BasicBlock::Create(gIR->context(), "foreachrange_cond", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bodybb = llvm::BasicBlock::Create(gIR->context(), "foreachrange_body", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* nextbb = llvm::BasicBlock::Create(gIR->context(), "foreachrange_next", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "foreachrange_end", p->topfunc(), oldend);
|
||||
|
||||
// jump to condition
|
||||
llvm::BranchInst::Create(condbb, p->scopebb());
|
||||
@@ -1268,7 +1268,7 @@ void LabelStatement::toIR(IRState* p)
|
||||
if (labelBB != NULL) {
|
||||
labelBB->moveBefore(oldend);
|
||||
} else {
|
||||
labelBB = llvm::BasicBlock::Create("label_" + labelname, p->topfunc(), oldend);
|
||||
labelBB = llvm::BasicBlock::Create(gIR->context(), "label_" + labelname, p->topfunc(), oldend);
|
||||
}
|
||||
|
||||
if (!p->scopereturned())
|
||||
@@ -1295,7 +1295,7 @@ void GotoStatement::toIR(IRState* p)
|
||||
DtoDwarfStopPoint(loc.linnum);
|
||||
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergoto", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftergoto", p->topfunc(), oldend);
|
||||
|
||||
DtoGoto(loc, label->ident, enclosingFinally);
|
||||
|
||||
@@ -1313,7 +1313,7 @@ void GotoDefaultStatement::toIR(IRState* p)
|
||||
DtoDwarfStopPoint(loc.linnum);
|
||||
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergotodefault", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftergotodefault", p->topfunc(), oldend);
|
||||
|
||||
assert(!p->scopereturned());
|
||||
assert(sw->sdefault->bodyBB);
|
||||
@@ -1335,12 +1335,12 @@ void GotoCaseStatement::toIR(IRState* p)
|
||||
DtoDwarfStopPoint(loc.linnum);
|
||||
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergotocase", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "aftergotocase", p->topfunc(), oldend);
|
||||
|
||||
assert(!p->scopereturned());
|
||||
if (!cs->bodyBB)
|
||||
{
|
||||
cs->bodyBB = llvm::BasicBlock::Create("goto_case", p->topfunc(), p->scopeend());
|
||||
cs->bodyBB = llvm::BasicBlock::Create(gIR->context(), "goto_case", p->topfunc(), p->scopeend());
|
||||
}
|
||||
|
||||
DtoEnclosingHandlers(loc, sw);
|
||||
|
||||
@@ -162,22 +162,22 @@ size_t add_zeros(std::vector<llvm::Value*>& values, size_t diff)
|
||||
{
|
||||
if (is64 && diff % 8 == 0)
|
||||
{
|
||||
values.push_back(LLConstant::getNullValue(llvm::Type::Int64Ty));
|
||||
values.push_back(LLConstant::getNullValue(llvm::Type::getInt64Ty(gIR->context())));
|
||||
diff -= 8;
|
||||
}
|
||||
else if (diff % 4 == 0)
|
||||
{
|
||||
values.push_back(LLConstant::getNullValue(llvm::Type::Int32Ty));
|
||||
values.push_back(LLConstant::getNullValue(llvm::Type::getInt32Ty(gIR->context())));
|
||||
diff -= 4;
|
||||
}
|
||||
else if (diff % 2 == 0)
|
||||
{
|
||||
values.push_back(LLConstant::getNullValue(llvm::Type::Int16Ty));
|
||||
values.push_back(LLConstant::getNullValue(llvm::Type::getInt16Ty(gIR->context())));
|
||||
diff -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
values.push_back(LLConstant::getNullValue(llvm::Type::Int8Ty));
|
||||
values.push_back(LLConstant::getNullValue(llvm::Type::getInt8Ty(gIR->context())));
|
||||
diff -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::Attribut
|
||||
}
|
||||
++argidx;
|
||||
|
||||
args.push_back(gIR->ir->CreateBitCast(mem, getPtrToType(LLType::Int8Ty), "tmp"));
|
||||
args.push_back(gIR->ir->CreateBitCast(mem, getPtrToType(LLType::getInt8Ty(gIR->context())), "tmp"));
|
||||
if (unsigned atts = tf->fty.arg_argptr->attrs) {
|
||||
Attr.Index = argidx;
|
||||
Attr.Attrs = atts;
|
||||
@@ -529,7 +529,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
||||
|
||||
// void returns cannot not be named
|
||||
const char* varname = "";
|
||||
if (callableTy->getReturnType() != LLType::VoidTy)
|
||||
if (callableTy->getReturnType() != LLType::getVoidTy(gIR->context()))
|
||||
varname = "tmp";
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -361,13 +361,13 @@ static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit
|
||||
vals[4] = DtoConstInt(linnum);
|
||||
|
||||
// size in bits
|
||||
vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false);
|
||||
vals[5] = LLConstantInt::get(LLType::getInt64Ty(gIR->context()), getTypeBitSize(T), false);
|
||||
|
||||
// alignment in bits
|
||||
vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false);
|
||||
vals[6] = LLConstantInt::get(LLType::getInt64Ty(gIR->context()), getABITypeAlign(T)*8, false);
|
||||
|
||||
// offset in bits
|
||||
vals[7] = LLConstantInt::get(LLType::Int64Ty, 0, false);
|
||||
vals[7] = LLConstantInt::get(LLType::getInt64Ty(gIR->context()), 0, false);
|
||||
|
||||
// FIXME: dont know what this is
|
||||
vals[8] = DtoConstUint(0);
|
||||
|
||||
36
gen/toir.cpp
36
gen/toir.cpp
@@ -408,7 +408,7 @@ DValue* StringExp::toElem(IRState* p)
|
||||
if (cty->size() == 1) {
|
||||
uint8_t* str = (uint8_t*)string;
|
||||
std::string cont((char*)str, len);
|
||||
_init = LLConstantArray::get(cont,true);
|
||||
_init = LLConstantArray::get(p->context(), cont, true);
|
||||
}
|
||||
else if (cty->size() == 2) {
|
||||
uint16_t* str = (uint16_t*)string;
|
||||
@@ -438,7 +438,7 @@ DValue* StringExp::toElem(IRState* p)
|
||||
Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n';
|
||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(*gIR->module,at,true,_linkage,_init,".str");
|
||||
|
||||
llvm::ConstantInt* zero = LLConstantInt::get(LLType::Int32Ty, 0, false);
|
||||
llvm::ConstantInt* zero = LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0, false);
|
||||
LLConstant* idxs[2] = { zero, zero };
|
||||
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
||||
|
||||
@@ -479,7 +479,7 @@ LLConstant* StringExp::toConstElem(IRState* p)
|
||||
if (cty->size() == 1) {
|
||||
uint8_t* str = (uint8_t*)string;
|
||||
std::string cont((char*)str, len);
|
||||
_init = LLConstantArray::get(cont, nullterm);
|
||||
_init = LLConstantArray::get(p->context(), cont, nullterm);
|
||||
}
|
||||
else if (cty->size() == 2) {
|
||||
uint16_t* str = (uint16_t*)string;
|
||||
@@ -514,7 +514,7 @@ LLConstant* StringExp::toConstElem(IRState* p)
|
||||
llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;
|
||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(*gIR->module,_init->getType(),true,_linkage,_init,".str");
|
||||
|
||||
llvm::ConstantInt* zero = LLConstantInt::get(LLType::Int32Ty, 0, false);
|
||||
llvm::ConstantInt* zero = LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0, false);
|
||||
LLConstant* idxs[2] = { zero, zero };
|
||||
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
||||
|
||||
@@ -818,7 +818,7 @@ DValue* CallExp::toElem(IRState* p)
|
||||
DValue* expv = exp->toElem(p);
|
||||
if (expv->getType()->toBasetype()->ty != Tint32)
|
||||
expv = DtoCast(loc, expv, Type::tint32);
|
||||
return new DImValue(type, p->ir->CreateAlloca(LLType::Int8Ty, expv->getRVal(), ".alloca"));
|
||||
return new DImValue(type, p->ir->CreateAlloca(LLType::getInt8Ty(gIR->context()), expv->getRVal(), ".alloca"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1783,8 +1783,8 @@ DValue* AssertExp::toElem(IRState* p)
|
||||
{
|
||||
// create basic blocks
|
||||
llvm::BasicBlock* oldend = p->scopeend();
|
||||
llvm::BasicBlock* assertbb = llvm::BasicBlock::Create("assert", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("noassert", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* assertbb = llvm::BasicBlock::Create(gIR->context(), "assert", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* endbb = llvm::BasicBlock::Create(gIR->context(), "noassert", p->topfunc(), oldend);
|
||||
|
||||
// test condition
|
||||
LLValue* condval = DtoCast(loc, cond, Type::tbool)->getRVal();
|
||||
@@ -1831,8 +1831,8 @@ DValue* AndAndExp::toElem(IRState* p)
|
||||
DValue* u = e1->toElem(p);
|
||||
|
||||
llvm::BasicBlock* oldend = p->scopeend();
|
||||
llvm::BasicBlock* andand = llvm::BasicBlock::Create("andand", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* andandend = llvm::BasicBlock::Create("andandend", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* andand = llvm::BasicBlock::Create(gIR->context(), "andand", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* andandend = llvm::BasicBlock::Create(gIR->context(), "andandend", gIR->topfunc(), oldend);
|
||||
|
||||
LLValue* ubool = DtoCast(loc, u, Type::tbool)->getRVal();
|
||||
|
||||
@@ -1857,7 +1857,7 @@ DValue* AndAndExp::toElem(IRState* p)
|
||||
// No need to create a PHI node.
|
||||
resval = ubool;
|
||||
} else {
|
||||
llvm::PHINode* phi = p->ir->CreatePHI(LLType::Int1Ty, "andandval");
|
||||
llvm::PHINode* phi = p->ir->CreatePHI(LLType::getInt1Ty(gIR->context()), "andandval");
|
||||
// If we jumped over evaluation of the right-hand side,
|
||||
// the result is false. Otherwise it's the value of the right-hand side.
|
||||
phi->addIncoming(LLConstantInt::getFalse(gIR->context()), oldblock);
|
||||
@@ -1878,8 +1878,8 @@ DValue* OrOrExp::toElem(IRState* p)
|
||||
DValue* u = e1->toElem(p);
|
||||
|
||||
llvm::BasicBlock* oldend = p->scopeend();
|
||||
llvm::BasicBlock* oror = llvm::BasicBlock::Create("oror", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* ororend = llvm::BasicBlock::Create("ororend", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* oror = llvm::BasicBlock::Create(gIR->context(), "oror", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* ororend = llvm::BasicBlock::Create(gIR->context(), "ororend", gIR->topfunc(), oldend);
|
||||
|
||||
LLValue* ubool = DtoCast(loc, u, Type::tbool)->getRVal();
|
||||
|
||||
@@ -1904,7 +1904,7 @@ DValue* OrOrExp::toElem(IRState* p)
|
||||
// No need to create a PHI node.
|
||||
resval = ubool;
|
||||
} else {
|
||||
llvm::PHINode* phi = p->ir->CreatePHI(LLType::Int1Ty, "ororval");
|
||||
llvm::PHINode* phi = p->ir->CreatePHI(LLType::getInt1Ty(gIR->context()), "ororval");
|
||||
// If we jumped over evaluation of the right-hand side,
|
||||
// the result is true. Otherwise, it's the value of the right-hand side.
|
||||
phi->addIncoming(LLConstantInt::getTrue(gIR->context()), oldblock);
|
||||
@@ -1970,7 +1970,7 @@ DValue* HaltExp::toElem(IRState* p)
|
||||
// this is sensible, since someone might goto behind the assert
|
||||
// and prevents compiler errors if a terminator follows the assert
|
||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterhalt", p->topfunc(), oldend);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "afterhalt", p->topfunc(), oldend);
|
||||
p->scope() = IRScope(bb,oldend);
|
||||
|
||||
return 0;
|
||||
@@ -1986,7 +1986,7 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||
if(func->isStatic())
|
||||
error("can't take delegate of static function %s, it does not require a context ptr", func->toChars());
|
||||
|
||||
const LLPointerType* int8ptrty = getPtrToType(LLType::Int8Ty);
|
||||
const LLPointerType* int8ptrty = getPtrToType(LLType::getInt8Ty(gIR->context()));
|
||||
|
||||
assert(type->toBasetype()->ty == Tdelegate);
|
||||
const LLType* dgty = DtoType(type);
|
||||
@@ -2128,9 +2128,9 @@ DValue* CondExp::toElem(IRState* p)
|
||||
}
|
||||
|
||||
llvm::BasicBlock* oldend = p->scopeend();
|
||||
llvm::BasicBlock* condtrue = llvm::BasicBlock::Create("condtrue", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* condfalse = llvm::BasicBlock::Create("condfalse", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* condend = llvm::BasicBlock::Create("condend", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* condtrue = llvm::BasicBlock::Create(gIR->context(), "condtrue", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* condfalse = llvm::BasicBlock::Create(gIR->context(), "condfalse", gIR->topfunc(), oldend);
|
||||
llvm::BasicBlock* condend = llvm::BasicBlock::Create(gIR->context(), "condend", gIR->topfunc(), oldend);
|
||||
|
||||
DValue* c = econd->toElem(p);
|
||||
LLValue* cond_val = DtoCast(loc, c, Type::tbool)->getRVal();
|
||||
|
||||
@@ -180,7 +180,7 @@ const LLType* DtoType(Type* t)
|
||||
const LLType* DtoStructTypeFromArguments(Arguments* arguments)
|
||||
{
|
||||
if (!arguments)
|
||||
return LLType::VoidTy;
|
||||
return LLType::getVoidTy(gIR->context());
|
||||
|
||||
std::vector<const LLType*> types;
|
||||
for (size_t i = 0; i < arguments->dim; i++)
|
||||
@@ -199,8 +199,8 @@ const LLType* DtoStructTypeFromArguments(Arguments* arguments)
|
||||
const LLType* DtoTypeNotVoid(Type* t)
|
||||
{
|
||||
const LLType* lt = DtoType(t);
|
||||
if (lt == LLType::VoidTy)
|
||||
return LLType::Int8Ty;
|
||||
if (lt == LLType::getVoidTy(gIR->context()))
|
||||
return LLType::getInt8Ty(gIR->context());
|
||||
return lt;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ const LLIntegerType* DtoSize_t()
|
||||
// the type of size_t does not change once set
|
||||
static const LLIntegerType* t = NULL;
|
||||
if (t == NULL)
|
||||
t = (global.params.is64bit) ? LLType::Int64Ty : LLType::Int32Ty;
|
||||
t = (global.params.is64bit) ? LLType::getInt64Ty(gIR->context()) : LLType::getInt32Ty(gIR->context());
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ LLValue* DtoMemCmp(LLValue* lhs, LLValue* rhs, LLValue* nbytes)
|
||||
params[0] = getVoidPtrType();
|
||||
params[1] = getVoidPtrType();
|
||||
params[2] = DtoSize_t();
|
||||
const LLFunctionType* fty = LLFunctionType::get(LLType::Int32Ty, params, false);
|
||||
const LLFunctionType* fty = LLFunctionType::get(LLType::getInt32Ty(gIR->context()), params, false);
|
||||
fn = LLFunction::Create(fty, LLGlobalValue::ExternalLinkage, "memcmp", gIR->module);
|
||||
}
|
||||
|
||||
@@ -535,19 +535,19 @@ llvm::ConstantInt* DtoConstSize_t(uint64_t i)
|
||||
}
|
||||
llvm::ConstantInt* DtoConstUint(unsigned i)
|
||||
{
|
||||
return LLConstantInt::get(LLType::Int32Ty, i, false);
|
||||
return LLConstantInt::get(LLType::getInt32Ty(gIR->context()), i, false);
|
||||
}
|
||||
llvm::ConstantInt* DtoConstInt(int i)
|
||||
{
|
||||
return LLConstantInt::get(LLType::Int32Ty, i, true);
|
||||
return LLConstantInt::get(LLType::getInt32Ty(gIR->context()), i, true);
|
||||
}
|
||||
LLConstant* DtoConstBool(bool b)
|
||||
{
|
||||
return LLConstantInt::get(LLType::Int1Ty, b, false);
|
||||
return LLConstantInt::get(LLType::getInt1Ty(gIR->context()), b, false);
|
||||
}
|
||||
llvm::ConstantInt* DtoConstUbyte(unsigned char i)
|
||||
{
|
||||
return LLConstantInt::get(LLType::Int8Ty, i, false);
|
||||
return LLConstantInt::get(LLType::getInt8Ty(gIR->context()), i, false);
|
||||
}
|
||||
|
||||
LLConstant* DtoConstFP(Type* t, long double value)
|
||||
@@ -555,9 +555,9 @@ LLConstant* DtoConstFP(Type* t, long double value)
|
||||
const LLType* llty = DtoType(t);
|
||||
assert(llty->isFloatingPoint());
|
||||
|
||||
if(llty == LLType::FloatTy || llty == LLType::DoubleTy)
|
||||
if(llty == LLType::getFloatTy(gIR->context()) || llty == LLType::getDoubleTy(gIR->context()))
|
||||
return LLConstantFP::get(llty, value);
|
||||
else if(llty == LLType::X86_FP80Ty) {
|
||||
else if(llty == LLType::getX86_FP80Ty(gIR->context())) {
|
||||
uint64_t bits[] = {0, 0};
|
||||
bits[0] = *(uint64_t*)&value;
|
||||
bits[1] = *(uint16_t*)((uint64_t*)&value + 1);
|
||||
@@ -572,7 +572,7 @@ LLConstant* DtoConstFP(Type* t, long double value)
|
||||
LLConstant* DtoConstString(const char* str)
|
||||
{
|
||||
std::string s(str?str:"");
|
||||
LLConstant* init = LLConstantArray::get(s, true);
|
||||
LLConstant* init = LLConstantArray::get(gIR->context(), s, true);
|
||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
|
||||
*gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str");
|
||||
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
||||
@@ -584,7 +584,7 @@ LLConstant* DtoConstString(const char* str)
|
||||
LLConstant* DtoConstStringPtr(const char* str, const char* section)
|
||||
{
|
||||
std::string s(str);
|
||||
LLConstant* init = LLConstantArray::get(s, true);
|
||||
LLConstant* init = LLConstantArray::get(gIR->context(), s, true);
|
||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
|
||||
*gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str");
|
||||
if (section) gvar->setSection(section);
|
||||
@@ -722,14 +722,14 @@ llvm::GlobalVariable* isaGlobalVar(LLValue* v)
|
||||
|
||||
const LLPointerType* getPtrToType(const LLType* t)
|
||||
{
|
||||
if (t == LLType::VoidTy)
|
||||
t = LLType::Int8Ty;
|
||||
if (t == LLType::getVoidTy(gIR->context()))
|
||||
t = LLType::getInt8Ty(gIR->context());
|
||||
return LLPointerType::get(t, 0);
|
||||
}
|
||||
|
||||
const LLPointerType* getVoidPtrType()
|
||||
{
|
||||
return getPtrToType(LLType::Int8Ty);
|
||||
return getPtrToType(LLType::getInt8Ty(gIR->context()));
|
||||
}
|
||||
|
||||
llvm::ConstantPointerNull* getNullPtr(const LLType* t)
|
||||
@@ -815,11 +815,11 @@ const LLStructType* DtoInterfaceInfoType()
|
||||
// void*[] vtbl
|
||||
std::vector<const LLType*> vtbltypes;
|
||||
vtbltypes.push_back(DtoSize_t());
|
||||
const LLType* byteptrptrty = getPtrToType(getPtrToType(LLType::Int8Ty));
|
||||
const LLType* byteptrptrty = getPtrToType(getPtrToType(LLType::getInt8Ty(gIR->context())));
|
||||
vtbltypes.push_back(byteptrptrty);
|
||||
types.push_back(LLStructType::get(gIR->context(), vtbltypes));
|
||||
// int offset
|
||||
types.push_back(LLType::Int32Ty);
|
||||
types.push_back(LLType::getInt32Ty(gIR->context()));
|
||||
// create type
|
||||
gIR->interfaceInfoType = LLStructType::get(gIR->context(), types);
|
||||
|
||||
@@ -837,7 +837,7 @@ const LLStructType* DtoMutexType()
|
||||
if (global.params.os == OSWindows)
|
||||
{
|
||||
// CRITICAL_SECTION.sizeof == 68
|
||||
std::vector<const LLType*> types(17, LLType::Int32Ty);
|
||||
std::vector<const LLType*> types(17, LLType::getInt32Ty(gIR->context()));
|
||||
return LLStructType::get(gIR->context(), types);
|
||||
}
|
||||
|
||||
@@ -850,20 +850,20 @@ const LLStructType* DtoMutexType()
|
||||
// pthread_fastlock
|
||||
std::vector<const LLType*> types2;
|
||||
types2.push_back(DtoSize_t());
|
||||
types2.push_back(LLType::Int32Ty);
|
||||
types2.push_back(LLType::getInt32Ty(gIR->context()));
|
||||
const LLStructType* fastlock = LLStructType::get(gIR->context(), types2);
|
||||
|
||||
// pthread_mutex
|
||||
std::vector<const LLType*> types1;
|
||||
types1.push_back(LLType::Int32Ty);
|
||||
types1.push_back(LLType::Int32Ty);
|
||||
types1.push_back(LLType::getInt32Ty(gIR->context()));
|
||||
types1.push_back(LLType::getInt32Ty(gIR->context()));
|
||||
types1.push_back(getVoidPtrType());
|
||||
types1.push_back(LLType::Int32Ty);
|
||||
types1.push_back(LLType::getInt32Ty(gIR->context()));
|
||||
types1.push_back(fastlock);
|
||||
const LLStructType* pmutex = LLStructType::get(gIR->context(), types1);
|
||||
|
||||
// D_CRITICAL_SECTION
|
||||
LLOpaqueType* opaque = LLOpaqueType::get();
|
||||
LLOpaqueType* opaque = LLOpaqueType::get(gIR->context());
|
||||
std::vector<const LLType*> types;
|
||||
types.push_back(getPtrToType(opaque));
|
||||
types.push_back(pmutex);
|
||||
@@ -887,7 +887,7 @@ const LLStructType* DtoModuleReferenceType()
|
||||
return gIR->moduleRefType;
|
||||
|
||||
// this is a recursive type so start out with the opaque
|
||||
LLOpaqueType* opaque = LLOpaqueType::get();
|
||||
LLOpaqueType* opaque = LLOpaqueType::get(gIR->context());
|
||||
|
||||
// add members
|
||||
std::vector<const LLType*> types;
|
||||
|
||||
@@ -424,12 +424,12 @@ llvm::Function* build_module_ctor()
|
||||
name.append("6__ctorZ");
|
||||
|
||||
std::vector<const LLType*> argsTy;
|
||||
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy,argsTy,false);
|
||||
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::getVoidTy(gIR->context()),argsTy,false);
|
||||
assert(gIR->module->getFunction(name) == NULL);
|
||||
llvm::Function* fn = llvm::Function::Create(fnTy, llvm::GlobalValue::InternalLinkage, name, gIR->module);
|
||||
fn->setCallingConv(DtoCallingConv(0, LINKd));
|
||||
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("entry", fn);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "entry", fn);
|
||||
IRBuilder<> builder(bb);
|
||||
|
||||
// debug info
|
||||
@@ -469,12 +469,12 @@ static llvm::Function* build_module_dtor()
|
||||
name.append("6__dtorZ");
|
||||
|
||||
std::vector<const LLType*> argsTy;
|
||||
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy,argsTy,false);
|
||||
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::getVoidTy(gIR->context()),argsTy,false);
|
||||
assert(gIR->module->getFunction(name) == NULL);
|
||||
llvm::Function* fn = llvm::Function::Create(fnTy, llvm::GlobalValue::InternalLinkage, name, gIR->module);
|
||||
fn->setCallingConv(DtoCallingConv(0, LINKd));
|
||||
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("entry", fn);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "entry", fn);
|
||||
IRBuilder<> builder(bb);
|
||||
|
||||
// debug info
|
||||
@@ -514,12 +514,12 @@ static llvm::Function* build_module_unittest()
|
||||
name.append("10__unittestZ");
|
||||
|
||||
std::vector<const LLType*> argsTy;
|
||||
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::VoidTy,argsTy,false);
|
||||
const llvm::FunctionType* fnTy = llvm::FunctionType::get(LLType::getVoidTy(gIR->context()),argsTy,false);
|
||||
assert(gIR->module->getFunction(name) == NULL);
|
||||
llvm::Function* fn = llvm::Function::Create(fnTy, llvm::GlobalValue::InternalLinkage, name, gIR->module);
|
||||
fn->setCallingConv(DtoCallingConv(0, LINKd));
|
||||
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("entry", fn);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "entry", fn);
|
||||
IRBuilder<> builder(bb);
|
||||
|
||||
// debug info
|
||||
@@ -547,7 +547,7 @@ static llvm::Function* build_module_unittest()
|
||||
static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo)
|
||||
{
|
||||
// build ctor type
|
||||
const LLFunctionType* fty = LLFunctionType::get(LLType::VoidTy, std::vector<const LLType*>(), false);
|
||||
const LLFunctionType* fty = LLFunctionType::get(LLType::getVoidTy(gIR->context()), std::vector<const LLType*>(), false);
|
||||
|
||||
// build ctor name
|
||||
std::string fname = "_D";
|
||||
@@ -576,7 +576,7 @@ static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo)
|
||||
mref = new LLGlobalVariable(*gIR->module, getPtrToType(modulerefTy), false, LLGlobalValue::ExternalLinkage, NULL, "_Dmodule_ref");
|
||||
|
||||
// make the function insert this moduleinfo as the beginning of the _Dmodule_ref linked list
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create("moduleinfoCtorEntry", ctor);
|
||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "moduleinfoCtorEntry", ctor);
|
||||
IRBuilder<> builder(bb);
|
||||
|
||||
// debug info
|
||||
@@ -746,7 +746,7 @@ void Module::genmoduleinfo()
|
||||
b.push_uint(mi_flags);
|
||||
|
||||
// function pointer type for next three fields
|
||||
const LLType* fnptrTy = getPtrToType(LLFunctionType::get(LLType::VoidTy, std::vector<const LLType*>(), false));
|
||||
const LLType* fnptrTy = getPtrToType(LLFunctionType::get(LLType::getVoidTy(gIR->context()), std::vector<const LLType*>(), false));
|
||||
|
||||
// ctor
|
||||
llvm::Function* fctor = build_module_ctor();
|
||||
@@ -807,9 +807,9 @@ void Module::genmoduleinfo()
|
||||
LLFunction* mictor = build_module_reference_and_ctor(gvar);
|
||||
|
||||
// register this ctor in the magic llvm.global_ctors appending array
|
||||
const LLFunctionType* magicfty = LLFunctionType::get(LLType::VoidTy, std::vector<const LLType*>(), false);
|
||||
const LLFunctionType* magicfty = LLFunctionType::get(LLType::getVoidTy(gIR->context()), std::vector<const LLType*>(), false);
|
||||
std::vector<const LLType*> magictypes;
|
||||
magictypes.push_back(LLType::Int32Ty);
|
||||
magictypes.push_back(LLType::getInt32Ty(gIR->context()));
|
||||
magictypes.push_back(getPtrToType(magicfty));
|
||||
const LLStructType* magicsty = LLStructType::get(gIR->context(), magictypes);
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ void DtoResolveTypeInfo(TypeInfoDeclaration* tid)
|
||||
// Construct the metadata
|
||||
llvm::MetadataBase* metadata = llvm::MDNode::get(gIR->context(), mdVals, TD_NumFields);
|
||||
// Insert it into the module
|
||||
llvm::NamedMDNode::Create(metaname, &metadata, 1, gIR->module);
|
||||
llvm::NamedMDNode::Create(gIR->context(), metaname, &metadata, 1, gIR->module);
|
||||
}
|
||||
}
|
||||
#endif // USE_METADATA
|
||||
|
||||
@@ -83,13 +83,13 @@ LLGlobalVariable * IrStruct::getClassInfoSymbol()
|
||||
// Construct the fields
|
||||
MDNodeField* mdVals[CD_NumFields];
|
||||
mdVals[CD_BodyType] = llvm::UndefValue::get(bodyType);
|
||||
mdVals[CD_Finalize] = LLConstantInt::get(LLType::Int1Ty, hasDestructor);
|
||||
mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::Int1Ty, hasCustomDelete);
|
||||
mdVals[CD_Finalize] = LLConstantInt::get(LLType::getInt1Ty(gIR->context()), hasDestructor);
|
||||
mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::getInt1Ty(gIR->context()), hasCustomDelete);
|
||||
// Construct the metadata
|
||||
llvm::MetadataBase* metadata = llvm::MDNode::get(gIR->context(), mdVals, CD_NumFields);
|
||||
// Insert it into the module
|
||||
std::string metaname = CD_PREFIX + initname;
|
||||
llvm::NamedMDNode::Create(metaname, &metadata, 1, gIR->module);
|
||||
llvm::NamedMDNode::Create(gIR->context(), metaname, &metadata, 1, gIR->module);
|
||||
}
|
||||
#endif // USE_METADATA
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
IRLandingPadInfo::IRLandingPadInfo(Catch* catchstmt, llvm::BasicBlock* end)
|
||||
: finallyBody(NULL)
|
||||
{
|
||||
target = llvm::BasicBlock::Create("catch", gIR->topfunc(), end);
|
||||
target = llvm::BasicBlock::Create(gIR->context(), "catch", gIR->topfunc(), end);
|
||||
gIR->scope() = IRScope(target,end);
|
||||
|
||||
// assign storage to catch var
|
||||
@@ -133,11 +133,11 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB)
|
||||
}
|
||||
// if there's a finally, the eh table has to have a 0 action
|
||||
if(hasFinally)
|
||||
selectorargs.push_back(LLConstantInt::get(LLType::Int32Ty, 0));
|
||||
selectorargs.push_back(LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0));
|
||||
|
||||
// personality fn
|
||||
llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_personality");
|
||||
LLValue* personality_fn_arg = gIR->ir->CreateBitCast(personality_fn, getPtrToType(LLType::Int8Ty));
|
||||
LLValue* personality_fn_arg = gIR->ir->CreateBitCast(personality_fn, getPtrToType(LLType::getInt8Ty(gIR->context())));
|
||||
selectorargs.insert(selectorargs.begin(), personality_fn_arg);
|
||||
|
||||
// eh storage target
|
||||
@@ -181,7 +181,7 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB)
|
||||
{
|
||||
if(!switchinst)
|
||||
{
|
||||
switchinst = gIR->ir->CreateSwitch(eh_sel, llvm::BasicBlock::Create("switchdefault", gIR->topfunc(), gIR->scopeend()), infos.size());
|
||||
switchinst = gIR->ir->CreateSwitch(eh_sel, llvm::BasicBlock::Create(gIR->context(), "switchdefault", gIR->topfunc(), gIR->scopeend()), infos.size());
|
||||
gIR->scope() = IRScope(switchinst->getDefaultDest(), gIR->scopeend());
|
||||
}
|
||||
// dubious comment
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
IrStruct::IrStruct(AggregateDeclaration* aggr)
|
||||
: diCompositeType(NULL),
|
||||
init_pa(llvm::OpaqueType::get())
|
||||
init_pa(llvm::OpaqueType::get(gIR->context()))
|
||||
{
|
||||
aggrdecl = aggr;
|
||||
|
||||
@@ -117,22 +117,22 @@ size_t add_zeros(std::vector<llvm::Constant*>& constants, size_t diff)
|
||||
{
|
||||
if (global.params.is64bit && diff % 8 == 0)
|
||||
{
|
||||
constants.push_back(LLConstant::getNullValue(llvm::Type::Int64Ty));
|
||||
constants.push_back(LLConstant::getNullValue(llvm::Type::getInt64Ty(gIR->context())));
|
||||
diff -= 8;
|
||||
}
|
||||
else if (diff % 4 == 0)
|
||||
{
|
||||
constants.push_back(LLConstant::getNullValue(llvm::Type::Int32Ty));
|
||||
constants.push_back(LLConstant::getNullValue(llvm::Type::getInt32Ty(gIR->context())));
|
||||
diff -= 4;
|
||||
}
|
||||
else if (diff % 2 == 0)
|
||||
{
|
||||
constants.push_back(LLConstant::getNullValue(llvm::Type::Int16Ty));
|
||||
constants.push_back(LLConstant::getNullValue(llvm::Type::getInt16Ty(gIR->context())));
|
||||
diff -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
constants.push_back(LLConstant::getNullValue(llvm::Type::Int8Ty));
|
||||
constants.push_back(LLConstant::getNullValue(llvm::Type::getInt8Ty(gIR->context())));
|
||||
diff -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,69 +43,70 @@ const llvm::Type * IrTypeBasic::basic2llvm(Type* t)
|
||||
{
|
||||
const llvm::Type* t2;
|
||||
|
||||
// FIXME: don't use getGlobalContext
|
||||
switch(t->ty)
|
||||
{
|
||||
case Tvoid:
|
||||
return llvm::Type::VoidTy;
|
||||
return llvm::Type::getVoidTy(llvm::getGlobalContext());
|
||||
|
||||
case Tint8:
|
||||
case Tuns8:
|
||||
case Tchar:
|
||||
return llvm::Type::Int8Ty;
|
||||
return llvm::Type::getInt8Ty(llvm::getGlobalContext());
|
||||
|
||||
case Tint16:
|
||||
case Tuns16:
|
||||
case Twchar:
|
||||
return llvm::Type::Int16Ty;
|
||||
return llvm::Type::getInt16Ty(llvm::getGlobalContext());
|
||||
|
||||
case Tint32:
|
||||
case Tuns32:
|
||||
case Tdchar:
|
||||
return llvm::Type::Int32Ty;
|
||||
return llvm::Type::getInt32Ty(llvm::getGlobalContext());
|
||||
|
||||
case Tint64:
|
||||
case Tuns64:
|
||||
return llvm::Type::Int64Ty;
|
||||
return llvm::Type::getInt64Ty(llvm::getGlobalContext());
|
||||
|
||||
/*
|
||||
case Tint128:
|
||||
case Tuns128:
|
||||
return llvm::IntegerType::get(128);
|
||||
return llvm::IntegerType::get(llvm::getGlobalContext(), 128);
|
||||
*/
|
||||
|
||||
case Tfloat32:
|
||||
case Timaginary32:
|
||||
return llvm::Type::FloatTy;
|
||||
return llvm::Type::getFloatTy(llvm::getGlobalContext());
|
||||
|
||||
case Tfloat64:
|
||||
case Timaginary64:
|
||||
return llvm::Type::DoubleTy;
|
||||
return llvm::Type::getDoubleTy(llvm::getGlobalContext());
|
||||
|
||||
case Tfloat80:
|
||||
case Timaginary80:
|
||||
// only x86 has 80bit float
|
||||
if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
|
||||
return llvm::Type::X86_FP80Ty;
|
||||
return llvm::Type::getX86_FP80Ty(llvm::getGlobalContext());
|
||||
// other platforms use 64bit reals
|
||||
else
|
||||
return llvm::Type::DoubleTy;
|
||||
return llvm::Type::getDoubleTy(llvm::getGlobalContext());
|
||||
|
||||
case Tcomplex32:
|
||||
t2 = llvm::Type::FloatTy;
|
||||
return llvm::StructType::get(gIR->context(), t2, t2, NULL);
|
||||
t2 = llvm::Type::getFloatTy(llvm::getGlobalContext());
|
||||
return llvm::StructType::get(llvm::getGlobalContext(), t2, t2, NULL);
|
||||
|
||||
case Tcomplex64:
|
||||
t2 = llvm::Type::DoubleTy;
|
||||
return llvm::StructType::get(gIR->context(), t2, t2, NULL);
|
||||
t2 = llvm::Type::getDoubleTy(llvm::getGlobalContext());
|
||||
return llvm::StructType::get(llvm::getGlobalContext(), t2, t2, NULL);
|
||||
|
||||
case Tcomplex80:
|
||||
t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
|
||||
? llvm::Type::X86_FP80Ty
|
||||
: llvm::Type::DoubleTy;
|
||||
return llvm::StructType::get(gIR->context(), t2, t2, NULL);
|
||||
? llvm::Type::getX86_FP80Ty(llvm::getGlobalContext())
|
||||
: llvm::Type::getDoubleTy(llvm::getGlobalContext());
|
||||
return llvm::StructType::get(llvm::getGlobalContext(), t2, t2, NULL);
|
||||
|
||||
case Tbool:
|
||||
return llvm::Type::Int1Ty;
|
||||
return llvm::Type::getInt1Ty(llvm::getGlobalContext());
|
||||
}
|
||||
|
||||
assert(0 && "not basic type");
|
||||
@@ -117,7 +118,7 @@ const llvm::Type * IrTypeBasic::basic2llvm(Type* t)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IrTypePointer::IrTypePointer(Type * dt)
|
||||
: IrType(dt, llvm::OpaqueType::get())
|
||||
: IrType(dt, llvm::OpaqueType::get(llvm::getGlobalContext()))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -137,8 +138,8 @@ const llvm::Type * IrTypePointer::pointer2llvm(Type * dt)
|
||||
assert(dt->ty == Tpointer && "not pointer type");
|
||||
|
||||
const llvm::Type* elemType = DtoType(dt->nextOf());
|
||||
if (elemType == llvm::Type::VoidTy)
|
||||
elemType = llvm::Type::Int8Ty;
|
||||
if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
|
||||
elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext());
|
||||
return llvm::PointerType::get(elemType, 0);
|
||||
}
|
||||
|
||||
@@ -147,7 +148,7 @@ const llvm::Type * IrTypePointer::pointer2llvm(Type * dt)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IrTypeSArray::IrTypeSArray(Type * dt)
|
||||
: IrType(dt, llvm::OpaqueType::get())
|
||||
: IrType(dt, llvm::OpaqueType::get(llvm::getGlobalContext()))
|
||||
{
|
||||
assert(dt->ty == Tsarray && "not static array type");
|
||||
TypeSArray* tsa = (TypeSArray*)dt;
|
||||
@@ -168,8 +169,8 @@ const llvm::Type * IrTypeSArray::buildType()
|
||||
const llvm::Type * IrTypeSArray::sarray2llvm(Type * t)
|
||||
{
|
||||
const llvm::Type* elemType = DtoType(t->nextOf());
|
||||
if (elemType == llvm::Type::VoidTy)
|
||||
elemType = llvm::Type::Int8Ty;
|
||||
if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
|
||||
elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext());
|
||||
return llvm::ArrayType::get(elemType, dim);
|
||||
}
|
||||
|
||||
@@ -178,7 +179,7 @@ const llvm::Type * IrTypeSArray::sarray2llvm(Type * t)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IrTypeArray::IrTypeArray(Type * dt)
|
||||
: IrType(dt, llvm::OpaqueType::get())
|
||||
: IrType(dt, llvm::OpaqueType::get(llvm::getGlobalContext()))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -199,12 +200,12 @@ const llvm::Type * IrTypeArray::array2llvm(Type * t)
|
||||
|
||||
// get .ptr type
|
||||
const llvm::Type* elemType = DtoType(t->nextOf());
|
||||
if (elemType == llvm::Type::VoidTy)
|
||||
elemType = llvm::Type::Int8Ty;
|
||||
if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
|
||||
elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext());
|
||||
elemType = llvm::PointerType::get(elemType, 0);
|
||||
|
||||
// create struct type
|
||||
const llvm::Type* at = llvm::StructType::get(gIR->context(), DtoSize_t(), elemType, NULL);
|
||||
const llvm::Type* at = llvm::StructType::get(llvm::getGlobalContext(), DtoSize_t(), elemType, NULL);
|
||||
|
||||
// name dynamic array types
|
||||
Type::sir->getState()->module->addTypeName(t->toChars(), at);
|
||||
|
||||
@@ -23,7 +23,7 @@ IrTypeClass::IrTypeClass(ClassDeclaration* cd)
|
||||
: IrTypeAggr(cd),
|
||||
cd(cd),
|
||||
tc((TypeClass*)cd->type),
|
||||
vtbl_pa(llvm::OpaqueType::get())
|
||||
vtbl_pa(llvm::OpaqueType::get(gIR->context()))
|
||||
{
|
||||
vtbl_size = cd->vtbl.dim;
|
||||
num_interface_vtbls = 0;
|
||||
@@ -234,7 +234,7 @@ const llvm::Type* IrTypeClass::buildType()
|
||||
else
|
||||
{
|
||||
// add monitor
|
||||
defaultTypes.push_back(llvm::PointerType::get(llvm::Type::Int8Ty, 0));
|
||||
defaultTypes.push_back(llvm::PointerType::get(llvm::Type::getInt8Ty(gIR->context()), 0));
|
||||
|
||||
// we start right after the vtbl and monitor
|
||||
size_t offset = PTRSIZE * 2;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "ir/irtypefunction.h"
|
||||
|
||||
IrTypeFunction::IrTypeFunction(Type * dt)
|
||||
: IrType(dt, llvm::OpaqueType::get())
|
||||
: IrType(dt, llvm::OpaqueType::get(gIR->context()))
|
||||
{
|
||||
irfty = NULL;
|
||||
}
|
||||
@@ -29,7 +29,7 @@ const llvm::Type * IrTypeFunction::buildType()
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IrTypeDelegate::IrTypeDelegate(Type * dt)
|
||||
: IrType(dt, llvm::OpaqueType::get())
|
||||
: IrType(dt, llvm::OpaqueType::get(gIR->context()))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IrTypeAggr::IrTypeAggr(AggregateDeclaration * ad)
|
||||
: IrType(ad->type, llvm::OpaqueType::get()),
|
||||
: IrType(ad->type, llvm::OpaqueType::get(gIR->context())),
|
||||
aggr(ad)
|
||||
{
|
||||
}
|
||||
@@ -41,22 +41,22 @@ size_t add_zeros(std::vector<const llvm::Type*>& defaultTypes, size_t diff)
|
||||
{
|
||||
if (global.params.is64bit && diff % 8 == 0)
|
||||
{
|
||||
defaultTypes.push_back(llvm::Type::Int64Ty);
|
||||
defaultTypes.push_back(llvm::Type::getInt64Ty(gIR->context()));
|
||||
diff -= 8;
|
||||
}
|
||||
else if (diff % 4 == 0)
|
||||
{
|
||||
defaultTypes.push_back(llvm::Type::Int32Ty);
|
||||
defaultTypes.push_back(llvm::Type::getInt32Ty(gIR->context()));
|
||||
diff -= 4;
|
||||
}
|
||||
else if (diff % 2 == 0)
|
||||
{
|
||||
defaultTypes.push_back(llvm::Type::Int16Ty);
|
||||
defaultTypes.push_back(llvm::Type::getInt16Ty(gIR->context()));
|
||||
diff -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultTypes.push_back(llvm::Type::Int8Ty);
|
||||
defaultTypes.push_back(llvm::Type::getInt8Ty(gIR->context()));
|
||||
diff -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ IrVar::IrVar(VarDeclaration* var)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IrGlobal::IrGlobal(VarDeclaration* v): IrVar(v),
|
||||
type(llvm::OpaqueType::get())
|
||||
type(llvm::OpaqueType::get(llvm::getGlobalContext()))
|
||||
{
|
||||
constInit = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user