LLVMContext changes up to r77366

This commit is contained in:
Benjamin Kramer 2009-07-30 15:25:10 +02:00
parent 3f0a0686a8
commit 66101517d7
19 changed files with 113 additions and 114 deletions

View file

@ -60,7 +60,7 @@ struct X86_cfloat_rewrite : ABIRewrite
rpart = gIR->ir->CreateBitCast(rpart, LLType::FloatTy, ".re"); rpart = gIR->ir->CreateBitCast(rpart, LLType::FloatTy, ".re");
// extract imag part // extract imag part
LLValue* ipart = gIR->ir->CreateLShr(in, gIR->context().getConstantInt(LLType::Int64Ty, 32, false)); LLValue* ipart = gIR->ir->CreateLShr(in, LLConstantInt::get(LLType::Int64Ty, 32, false));
ipart = gIR->ir->CreateTrunc(ipart, LLType::Int32Ty); ipart = gIR->ir->CreateTrunc(ipart, LLType::Int32Ty);
ipart = gIR->ir->CreateBitCast(ipart, LLType::FloatTy, ".im"); ipart = gIR->ir->CreateBitCast(ipart, LLType::FloatTy, ".im");
@ -87,7 +87,7 @@ struct X86_cfloat_rewrite : ABIRewrite
// zext to i64 // zext to i64
i = gIR->ir->CreateZExt(i, LLType::Int64Ty); i = gIR->ir->CreateZExt(i, LLType::Int64Ty);
// shift up // shift up
i = gIR->ir->CreateShl(i, gIR->context().getConstantInt(LLType::Int64Ty, 32, false)); i = gIR->ir->CreateShl(i, LLConstantInt::get(LLType::Int64Ty, 32, false));
// combine and return // combine and return
return v = gIR->ir->CreateOr(r, i); return v = gIR->ir->CreateOr(r, i);

View file

@ -309,7 +309,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit)
LLConstant* constarr; LLConstant* constarr;
if (mismatch) if (mismatch)
constarr = gIR->context().getConstantStruct(initvals); constarr = LLConstantStruct::get(initvals);
else else
constarr = LLConstantArray::get(LLArrayType::get(llelemty, arrlen), initvals); constarr = LLConstantArray::get(LLArrayType::get(llelemty, arrlen), initvals);
@ -394,7 +394,7 @@ void DtoStaticArrayCopy(LLValue* dst, LLValue* src)
LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr) LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr)
{ {
LLConstant* values[2] = { dim, ptr }; LLConstant* values[2] = { dim, ptr };
return gIR->context().getConstantStruct(values, 2); return LLConstantStruct::get(values, 2);
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
@ -784,11 +784,11 @@ LLValue* DtoArrayCompare(Loc& loc, TOK op, DValue* l, DValue* r)
break; break;
case TOKleg: case TOKleg:
skip = true; skip = true;
res = gIR->context().getConstantIntTrue(); res = gIR->context().getTrue();
break; break;
case TOKunord: case TOKunord:
skip = true; skip = true;
res = gIR->context().getConstantIntFalse(); res = gIR->context().getFalse();
break; break;
default: default:
@ -826,8 +826,8 @@ LLValue* DtoArrayCastLength(LLValue* len, const LLType* elemty, const LLType* ne
LLSmallVector<LLValue*, 3> args; LLSmallVector<LLValue*, 3> args;
args.push_back(len); args.push_back(len);
args.push_back(gIR->context().getConstantInt(DtoSize_t(), esz, false)); args.push_back(LLConstantInt::get(DtoSize_t(), esz, false));
args.push_back(gIR->context().getConstantInt(DtoSize_t(), nsz, false)); args.push_back(LLConstantInt::get(DtoSize_t(), nsz, false));
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len"); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len");
return gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp").getInstruction(); return gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp").getInstruction();
@ -962,7 +962,7 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to)
fatal(); fatal();
} }
rval2 = gIR->context().getConstantInt(DtoSize_t(), arrty->getNumElements(), false); rval2 = LLConstantInt::get(DtoSize_t(), arrty->getNumElements(), false);
if (fromtype->nextOf()->size() != totype->nextOf()->size()) if (fromtype->nextOf()->size() != totype->nextOf()->size())
rval2 = DtoArrayCastLength(rval2, ety, ptrty->getContainedType(0)); rval2 = DtoArrayCastLength(rval2, ety, ptrty->getContainedType(0));
rval = DtoBitCast(uval, ptrty); rval = DtoBitCast(uval, ptrty);

View file

@ -769,7 +769,7 @@ void AsmBlockStatement::toIR(IRState* p)
for(it = gotoToVal.begin(); it != end; ++it) for(it = gotoToVal.begin(); it != end; ++it)
{ {
llvm::BasicBlock* casebb = llvm::BasicBlock::Create("case", p->topfunc(), bb); llvm::BasicBlock* casebb = llvm::BasicBlock::Create("case", p->topfunc(), bb);
sw->addCase(gIR->context().getConstantInt(llvm::IntegerType::get(32), it->second), casebb); sw->addCase(LLConstantInt::get(llvm::IntegerType::get(32), it->second), casebb);
p->scope() = IRScope(casebb,bb); p->scope() = IRScope(casebb,bb);
DtoGoto(loc, it->first, enclosingFinally); DtoGoto(loc, it->first, enclosingFinally);

View file

@ -606,7 +606,7 @@ static LLConstant* build_offti_array(ClassDeclaration* cd, const LLType* arrayT)
// array type // array type
const llvm::ArrayType* arrTy = llvm::ArrayType::get(arrayInits[0]->getType(), nvars); const llvm::ArrayType* arrTy = llvm::ArrayType::get(arrayInits[0]->getType(), nvars);
LLConstant* arrInit = llvm::ConstantArray::get(arrTy, arrayInits); LLConstant* arrInit = LLConstantArray::get(arrTy, arrayInits);
// mangle // mangle
std::string name(cd->type->vtinfo->toChars()); std::string name(cd->type->vtinfo->toChars());

View file

@ -514,7 +514,7 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to)
} }
if (to->ty == Tbool) { if (to->ty == Tbool) {
LLValue* zero = gIR->context().getConstantInt(rval->getType(), 0, false); LLValue* zero = LLConstantInt::get(rval->getType(), 0, false);
rval = gIR->ir->CreateICmpNE(rval, zero, "tmp"); rval = gIR->ir->CreateICmpNE(rval, zero, "tmp");
} }
else if (to->isintegral()) { else if (to->isintegral()) {

View file

@ -58,24 +58,24 @@ namespace {
// Helper functions // Helper functions
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void EmitMemSet(LLVMContext& Context, IRBuilder<>& B, Value* Dst, Value* Val, void EmitMemSet(IRBuilder<>& B, Value* Dst, Value* Val, Value* Len,
Value* Len, const Analysis& A) { const Analysis& A) {
Dst = B.CreateBitCast(Dst, PointerType::getUnqual(Type::Int8Ty)); Dst = B.CreateBitCast(Dst, PointerType::getUnqual(Type::Int8Ty));
Module *M = B.GetInsertBlock()->getParent()->getParent(); Module *M = B.GetInsertBlock()->getParent()->getParent();
const Type* Tys[1]; const Type* Tys[1];
Tys[0] = Len->getType(); Tys[0] = Len->getType();
Function *MemSet = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 1); Function *MemSet = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 1);
Value *Align = Context.getConstantInt(Type::Int32Ty, 1); Value *Align = ConstantInt::get(Type::Int32Ty, 1);
CallSite CS = B.CreateCall4(MemSet, Dst, Val, Len, Align); CallSite CS = B.CreateCall4(MemSet, Dst, Val, Len, Align);
if (A.CGNode) if (A.CGNode)
A.CGNode->addCalledFunction(CS, A.CG->getOrInsertFunction(MemSet)); A.CGNode->addCalledFunction(CS, A.CG->getOrInsertFunction(MemSet));
} }
static void EmitMemZero(LLVMContext& Context, IRBuilder<>& B, Value* Dst, static void EmitMemZero(IRBuilder<>& B, Value* Dst, Value* Len,
Value* Len, const Analysis& A) { const Analysis& A) {
EmitMemSet(Context, B, Dst, Context.getConstantInt(Type::Int8Ty, 0), Len, A); EmitMemSet(B, Dst, ConstantInt::get(Type::Int8Ty, 0), Len, A);
} }
@ -94,7 +94,7 @@ namespace {
// Analyze the current call, filling in some fields. Returns true if // Analyze the current call, filling in some fields. Returns true if
// this is an allocation we can stack-allocate. // this is an allocation we can stack-allocate.
virtual bool analyze(LLVMContext& context, CallSite CS, const Analysis& A) { virtual bool analyze(CallSite CS, const Analysis& A) {
Value* TypeInfo = CS.getArgument(TypeInfoArgNr); Value* TypeInfo = CS.getArgument(TypeInfoArgNr);
Ty = A.getTypeFor(TypeInfo); Ty = A.getTypeFor(TypeInfo);
return (Ty != NULL); return (Ty != NULL);
@ -102,7 +102,7 @@ namespace {
// Returns the alloca to replace this call. // Returns the alloca to replace this call.
// It will always be inserted before the call. // It will always be inserted before the call.
virtual AllocaInst* promote(LLVMContext& context, CallSite CS, IRBuilder<>& B, const Analysis& A) { virtual AllocaInst* promote(CallSite CS, IRBuilder<>& B, const Analysis& A) {
NumGcToStack++; NumGcToStack++;
Instruction* Begin = CS.getCaller()->getEntryBlock().begin(); Instruction* Begin = CS.getCaller()->getEntryBlock().begin();
@ -119,15 +119,15 @@ namespace {
bool Initialized; bool Initialized;
public: public:
ArrayFI(unsigned tiArgNr, bool safeToDelete, ArrayFI(unsigned tiArgNr, bool safeToDelete, bool initialized,
bool initialized, unsigned arrSizeArgNr) unsigned arrSizeArgNr)
: FunctionInfo(tiArgNr, safeToDelete), : FunctionInfo(tiArgNr, safeToDelete),
ArrSizeArgNr(arrSizeArgNr), ArrSizeArgNr(arrSizeArgNr),
Initialized(initialized) Initialized(initialized)
{} {}
virtual bool analyze(LLVMContext& context, CallSite CS, const Analysis& A) { virtual bool analyze(CallSite CS, const Analysis& A) {
if (!FunctionInfo::analyze(context, CS, A)) if (!FunctionInfo::analyze(CS, A))
return false; return false;
arrSize = CS.getArgument(ArrSizeArgNr); arrSize = CS.getArgument(ArrSizeArgNr);
@ -155,7 +155,7 @@ namespace {
return true; return true;
} }
virtual AllocaInst* promote(LLVMContext& context, CallSite CS, IRBuilder<>& B, const Analysis& A) { virtual AllocaInst* promote(CallSite CS, IRBuilder<>& B, const Analysis& A) {
IRBuilder<> Builder = B; IRBuilder<> Builder = B;
// If the allocation is of constant size it's best to put it in the // If the allocation is of constant size it's best to put it in the
// entry block, so do so if we're not already there. // entry block, so do so if we're not already there.
@ -178,11 +178,11 @@ namespace {
if (Initialized) { if (Initialized) {
// For now, only zero-init is supported. // For now, only zero-init is supported.
uint64_t size = A.TD.getTypeStoreSize(Ty); uint64_t size = A.TD.getTypeStoreSize(Ty);
Value* TypeSize = context.getConstantInt(arrSize->getType(), size); Value* TypeSize = ConstantInt::get(arrSize->getType(), size);
// Use the original B to put initialization at the // Use the original B to put initialization at the
// allocation site. // allocation site.
Value* Size = B.CreateMul(TypeSize, arrSize); Value* Size = B.CreateMul(TypeSize, arrSize);
EmitMemZero(context, B, alloca, Size, A); EmitMemZero(B, alloca, Size, A);
} }
return alloca; return alloca;
@ -192,7 +192,7 @@ namespace {
// FunctionInfo for _d_allocclass // FunctionInfo for _d_allocclass
class AllocClassFI : public FunctionInfo { class AllocClassFI : public FunctionInfo {
public: public:
virtual bool analyze(LLVMContext& context, CallSite CS, const Analysis& A) { virtual bool analyze(CallSite CS, const Analysis& A) {
// This call contains no TypeInfo parameter, so don't call the // This call contains no TypeInfo parameter, so don't call the
// base class implementation here... // base class implementation here...
if (CS.arg_size() != 1) if (CS.arg_size() != 1)
@ -223,8 +223,8 @@ namespace {
if (hasDestructor == NULL || hasCustomDelete == NULL) if (hasDestructor == NULL || hasCustomDelete == NULL)
return false; return false;
if (context.getConstantExprOr(hasDestructor, hasCustomDelete) if (ConstantExpr::getOr(hasDestructor, hasCustomDelete)
!= context.getConstantIntFalse()) != A.M.getContext().getFalse())
return false; return false;
Ty = MD_GetElement(node, CD_BodyType)->getType(); Ty = MD_GetElement(node, CD_BodyType)->getType();
@ -259,7 +259,6 @@ namespace {
GarbageCollect2Stack(); GarbageCollect2Stack();
bool doInitialization(Module &M) { bool doInitialization(Module &M) {
Context = &M.getContext();
this->M = &M; this->M = &M;
return false; return false;
} }
@ -297,7 +296,7 @@ GarbageCollect2Stack::GarbageCollect2Stack()
KnownFunctions["_d_allocclass"] = &AllocClass; KnownFunctions["_d_allocclass"] = &AllocClass;
} }
static void RemoveCall(LLVMContext& context, CallSite CS, const Analysis& A) { static void RemoveCall(CallSite CS, const Analysis& A) {
if (CS.isInvoke()) { if (CS.isInvoke()) {
InvokeInst* Invoke = cast<InvokeInst>(CS.getInstruction()); InvokeInst* Invoke = cast<InvokeInst>(CS.getInstruction());
// If this was an invoke instruction, we need to do some extra // If this was an invoke instruction, we need to do some extra
@ -306,7 +305,7 @@ static void RemoveCall(LLVMContext& context, CallSite CS, const Analysis& A) {
// Create a "conditional" branch that -simplifycfg can clean up, so we // Create a "conditional" branch that -simplifycfg can clean up, so we
// can keep using the DominatorTree without updating it. // can keep using the DominatorTree without updating it.
BranchInst::Create(Invoke->getNormalDest(), Invoke->getUnwindDest(), BranchInst::Create(Invoke->getNormalDest(), Invoke->getUnwindDest(),
context.getConstantIntTrue(), Invoke->getParent()); A.M.getContext().getTrue(), Invoke->getParent());
} }
// Remove the runtime call. // Remove the runtime call.
if (A.CGNode) if (A.CGNode)
@ -360,20 +359,20 @@ bool GarbageCollect2Stack::runOnFunction(Function &F) {
if (Inst->use_empty() && info->SafeToDelete) { if (Inst->use_empty() && info->SafeToDelete) {
Changed = true; Changed = true;
NumDeleted++; NumDeleted++;
RemoveCall(*Context, CS, A); RemoveCall(CS, A);
continue; continue;
} }
DEBUG(errs() << "GarbageCollect2Stack inspecting: " << *Inst); DEBUG(errs() << "GarbageCollect2Stack inspecting: " << *Inst);
if (!info->analyze(*Context, CS, A) || !isSafeToStackAllocate(Inst, DT)) if (!info->analyze(CS, A) || !isSafeToStackAllocate(Inst, DT))
continue; continue;
// Let's alloca this! // Let's alloca this!
Changed = true; Changed = true;
IRBuilder<> Builder(BB, Inst); IRBuilder<> Builder(BB, Inst);
Value* newVal = info->promote(*Context, CS, Builder, A); Value* newVal = info->promote(CS, Builder, A);
DEBUG(errs() << "Promoted to: " << *newVal); DEBUG(errs() << "Promoted to: " << *newVal);
@ -383,7 +382,7 @@ bool GarbageCollect2Stack::runOnFunction(Function &F) {
newVal = Builder.CreateBitCast(newVal, Inst->getType()); newVal = Builder.CreateBitCast(newVal, Inst->getType());
Inst->replaceAllUsesWith(newVal); Inst->replaceAllUsesWith(newVal);
RemoveCall(*Context, CS, A); RemoveCall(CS, A);
} }
} }

View file

@ -74,7 +74,7 @@ namespace {
this->TD = &TD; this->TD = &TD;
this->AA = &AA; this->AA = &AA;
if (CI->getCalledFunction()) if (CI->getCalledFunction())
Context = CI->getCalledFunction()->getContext(); Context = &CI->getCalledFunction()->getContext();
return CallOptimizer(CI->getCalledFunction(), CI, B); return CallOptimizer(CI->getCalledFunction(), CI, B);
} }
}; };
@ -95,7 +95,7 @@ Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
Tys[0] = Len->getType(); Tys[0] = Len->getType();
Value *MemCpy = Intrinsic::getDeclaration(M, IID, Tys, 1); Value *MemCpy = Intrinsic::getDeclaration(M, IID, Tys, 1);
return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src, B), Len, return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src, B), Len,
Context->getConstantInt(Type::Int32Ty, Align)); ConstantInt::get(Type::Int32Ty, Align));
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -181,7 +181,7 @@ struct VISIBILITY_HIDDEN ArrayCastLenOpt : public LibCallOptimization {
APInt Quot, Rem; APInt Quot, Rem;
APInt::udivrem(OldInt->getValue(), NewInt->getValue(), Quot, Rem); APInt::udivrem(OldInt->getValue(), NewInt->getValue(), Quot, Rem);
if (Rem == 0) if (Rem == 0)
return B.CreateMul(OldLen, Context->getConstantInt(Quot)); return B.CreateMul(OldLen, ConstantInt::get(*Context, Quot));
} }
return 0; return 0;
} }
@ -202,7 +202,7 @@ struct VISIBILITY_HIDDEN AllocationOpt : public LibCallOptimization {
Constant* C = 0; Constant* C = 0;
if ((C = dyn_cast<Constant>(Cmp->getOperand(0))) if ((C = dyn_cast<Constant>(Cmp->getOperand(0)))
|| (C = dyn_cast<Constant>(Cmp->getOperand(1)))) { || (C = dyn_cast<Constant>(Cmp->getOperand(1)))) {
Value* Result = Context->getConstantInt(Type::Int1Ty, !Cmp->isTrueWhenEqual()); Value* Result = ConstantInt::get(Type::Int1Ty, !Cmp->isTrueWhenEqual());
Cmp->replaceAllUsesWith(Result); Cmp->replaceAllUsesWith(Result);
// Don't delete the comparison because there may be an // Don't delete the comparison because there may be an
// iterator to it. Instead, set the operands to constants // iterator to it. Instead, set the operands to constants
@ -359,8 +359,8 @@ bool SimplifyDRuntimeCalls::runOnFunction(Function &F) {
} }
bool SimplifyDRuntimeCalls::runOnce(Function &F, const TargetData& TD, AliasAnalysis& AA) { bool SimplifyDRuntimeCalls::runOnce(Function &F, const TargetData& TD, AliasAnalysis& AA) {
IRBuilder<> Builder(*Context); IRBuilder<> Builder(F.getContext());
bool Changed = false; bool Changed = false;
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) { for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {

View file

@ -142,7 +142,7 @@ void RTTIBuilder::push_funcptr(FuncDeclaration* fd, Type* castto)
void RTTIBuilder::finalize(IrGlobal* tid) void RTTIBuilder::finalize(IrGlobal* tid)
{ {
// create the inititalizer // create the inititalizer
LLConstant* tiInit = gIR->context().getConstantStruct(&inits[0], inits.size(), false); LLConstant* tiInit = LLConstantStruct::get(&inits[0], inits.size(), false);
// refine global type // refine global type
llvm::cast<llvm::OpaqueType>(tid->type.get())->refineAbstractTypeTo(tiInit->getType()); llvm::cast<llvm::OpaqueType>(tid->type.get())->refineAbstractTypeTo(tiInit->getType());
@ -154,5 +154,5 @@ void RTTIBuilder::finalize(IrGlobal* tid)
LLConstant* RTTIBuilder::get_constant() LLConstant* RTTIBuilder::get_constant()
{ {
// just return the inititalizer // just return the inititalizer
return gIR->context().getConstantStruct(&inits[0], inits.size(), false); return LLConstantStruct::get(&inits[0], inits.size(), false);
} }

View file

@ -815,7 +815,7 @@ void SwitchStatement::toIR(IRState* p)
// build static array for ptr or final array // build static array for ptr or final array
const LLType* elemTy = DtoType(condition->type); const LLType* elemTy = DtoType(condition->type);
const llvm::ArrayType* arrTy = llvm::ArrayType::get(elemTy, inits.size()); const llvm::ArrayType* arrTy = llvm::ArrayType::get(elemTy, inits.size());
LLConstant* arrInit = llvm::ConstantArray::get(arrTy, inits); LLConstant* arrInit = LLConstantArray::get(arrTy, inits);
llvm::GlobalVariable* arr = new llvm::GlobalVariable(*gIR->module, arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, ".string_switch_table_data"); llvm::GlobalVariable* arr = new llvm::GlobalVariable(*gIR->module, arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, ".string_switch_table_data");
const LLType* elemPtrTy = getPtrToType(elemTy); const LLType* elemPtrTy = getPtrToType(elemTy);
@ -1030,7 +1030,7 @@ void ForeachStatement::toIR(IRState* p)
keyvar = DtoRawVarDeclaration(key); keyvar = DtoRawVarDeclaration(key);
else else
keyvar = DtoRawAlloca(keytype, 0, "foreachkey"); // FIXME: align? keyvar = DtoRawAlloca(keytype, 0, "foreachkey"); // FIXME: align?
LLValue* zerokey = gIR->context().getConstantInt(keytype,0,false); LLValue* zerokey = LLConstantInt::get(keytype,0,false);
// value // value
Logger::println("value = %s", value->toPrettyChars()); Logger::println("value = %s", value->toPrettyChars());
@ -1087,7 +1087,7 @@ void ForeachStatement::toIR(IRState* p)
} }
else if (op == TOKforeach_reverse) { else if (op == TOKforeach_reverse) {
done = p->ir->CreateICmpUGT(load, zerokey, "tmp"); done = p->ir->CreateICmpUGT(load, zerokey, "tmp");
load = p->ir->CreateSub(load, gIR->context().getConstantInt(keytype, 1, false), "tmp"); load = p->ir->CreateSub(load, LLConstantInt::get(keytype, 1, false), "tmp");
DtoStore(load, keyvar); DtoStore(load, keyvar);
} }
llvm::BranchInst::Create(bodybb, endbb, done, p->scopebb()); llvm::BranchInst::Create(bodybb, endbb, done, p->scopebb());
@ -1096,7 +1096,7 @@ void ForeachStatement::toIR(IRState* p)
p->scope() = IRScope(bodybb,nextbb); p->scope() = IRScope(bodybb,nextbb);
// get value for this iteration // get value for this iteration
LLConstant* zero = gIR->context().getConstantInt(keytype,0,false); LLConstant* zero = LLConstantInt::get(keytype,0,false);
LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp"); LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp");
LLValue* gep = DtoGEP1(val,loadedKey); LLValue* gep = DtoGEP1(val,loadedKey);
@ -1124,7 +1124,7 @@ void ForeachStatement::toIR(IRState* p)
p->scope() = IRScope(nextbb,endbb); p->scope() = IRScope(nextbb,endbb);
if (op == TOKforeach) { if (op == TOKforeach) {
LLValue* load = DtoLoad(keyvar); LLValue* load = DtoLoad(keyvar);
load = p->ir->CreateAdd(load, gIR->context().getConstantInt(keytype, 1, false), "tmp"); load = p->ir->CreateAdd(load, LLConstantInt::get(keytype, 1, false), "tmp");
DtoStore(load, keyvar); DtoStore(load, keyvar);
} }
llvm::BranchInst::Create(condbb, p->scopebb()); llvm::BranchInst::Create(condbb, p->scopebb());

View file

@ -108,7 +108,7 @@ LLValue* DtoStructEquals(TOK op, DValue* lhs, DValue* rhs)
// call memcmp // call memcmp
size_t sz = getTypePaddedSize(DtoType(t)); size_t sz = getTypePaddedSize(DtoType(t));
LLValue* val = DtoMemCmp(lhs->getRVal(), rhs->getRVal(), DtoConstSize_t(sz)); LLValue* val = DtoMemCmp(lhs->getRVal(), rhs->getRVal(), DtoConstSize_t(sz));
return gIR->ir->CreateICmp(cmpop, val, gIR->context().getConstantInt(val->getType(), 0, false), "tmp"); return gIR->ir->CreateICmp(cmpop, val, LLConstantInt::get(val->getType(), 0, false), "tmp");
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////

View file

@ -199,7 +199,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::Attribut
} }
// apply initializer // apply initializer
LLConstant* tiinits = llvm::ConstantArray::get(typeinfoarraytype, vtypeinfos); LLConstant* tiinits = LLConstantArray::get(typeinfoarraytype, vtypeinfos);
typeinfomem->setInitializer(tiinits); typeinfomem->setInitializer(tiinits);
// put data in d-array // put data in d-array
@ -207,7 +207,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::Attribut
pinits.push_back(DtoConstSize_t(vtype->getNumElements())); pinits.push_back(DtoConstSize_t(vtype->getNumElements()));
pinits.push_back(llvm::ConstantExpr::getBitCast(typeinfomem, getPtrToType(typeinfotype))); pinits.push_back(llvm::ConstantExpr::getBitCast(typeinfomem, getPtrToType(typeinfotype)));
const LLType* tiarrty = DtoType(Type::typeinfo->type->arrayOf()); const LLType* tiarrty = DtoType(Type::typeinfo->type->arrayOf());
tiinits = gIR->context().getConstantStruct(pinits); tiinits = LLConstantStruct::get(pinits);
LLValue* typeinfoarrayparam = new llvm::GlobalVariable(*gIR->module, tiarrty, LLValue* typeinfoarrayparam = new llvm::GlobalVariable(*gIR->module, tiarrty,
true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array"); true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array");

View file

@ -23,7 +23,7 @@ using namespace llvm::dwarf;
#define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) ) #define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) )
#define DBG_CAST(X) ( llvm::ConstantExpr::getBitCast(X, DBG_TYPE) ) #define DBG_CAST(X) ( llvm::ConstantExpr::getBitCast(X, DBG_TYPE) )
#define DBG_TAG(X) ( gIR->context().getConstantExprAdd( DtoConstUint( X ), DtoConstUint( llvm::LLVMDebugVersion ) ) ) #define DBG_TAG(X) ( llvm::ConstantExpr::getAdd( DtoConstUint( X ), DtoConstUint( llvm::LLVMDebugVersion ) ) )
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
@ -361,13 +361,13 @@ static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit
vals[4] = DtoConstInt(linnum); vals[4] = DtoConstInt(linnum);
// size in bits // size in bits
vals[5] = gIR->context().getConstantInt(LLType::Int64Ty, getTypeBitSize(T), false); vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false);
// alignment in bits // alignment in bits
vals[6] = gIR->context().getConstantInt(LLType::Int64Ty, getABITypeAlign(T)*8, false); vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false);
// offset in bits // offset in bits
vals[7] = gIR->context().getConstantInt(LLType::Int64Ty, 0, false); vals[7] = LLConstantInt::get(LLType::Int64Ty, 0, false);
// FIXME: dont know what this is // FIXME: dont know what this is
vals[8] = DtoConstUint(0); vals[8] = DtoConstUint(0);

View file

@ -288,11 +288,11 @@ LLConstant* IntegerExp::toConstElem(IRState* p)
const LLType* t = DtoType(type); const LLType* t = DtoType(type);
if (isaPointer(t)) { if (isaPointer(t)) {
Logger::println("pointer"); Logger::println("pointer");
LLConstant* i = gIR->context().getConstantInt(DtoSize_t(),(uint64_t)value,false); LLConstant* i = LLConstantInt::get(DtoSize_t(),(uint64_t)value,false);
return llvm::ConstantExpr::getIntToPtr(i, t); return llvm::ConstantExpr::getIntToPtr(i, t);
} }
assert(llvm::isa<LLIntegerType>(t)); assert(llvm::isa<LLIntegerType>(t));
LLConstant* c = gIR->context().getConstantInt(t,(uint64_t)value,!type->isunsigned()); LLConstant* c = LLConstantInt::get(t,(uint64_t)value,!type->isunsigned());
assert(c); assert(c);
if (Logger::enabled()) if (Logger::enabled())
Logger::cout() << "value = " << *c << '\n'; Logger::cout() << "value = " << *c << '\n';
@ -338,7 +338,7 @@ LLConstant* NullExp::toConstElem(IRState* p)
const LLType* t = DtoType(type); const LLType* t = DtoType(type);
if (type->ty == Tarray) { if (type->ty == Tarray) {
assert(isaStruct(t)); assert(isaStruct(t));
return llvm::ConstantAggregateZero::get(t); return gIR->context().getConstantAggregateZero(t);
} }
else { else {
return gIR->context().getNullValue(t); return gIR->context().getNullValue(t);
@ -402,27 +402,27 @@ DValue* StringExp::toElem(IRState* p)
if (cty->size() == 1) { if (cty->size() == 1) {
uint8_t* str = (uint8_t*)string; uint8_t* str = (uint8_t*)string;
std::string cont((char*)str, len); std::string cont((char*)str, len);
_init = gIR->context().getConstantArray(cont,true); _init = LLConstantArray::get(cont,true);
} }
else if (cty->size() == 2) { else if (cty->size() == 2) {
uint16_t* str = (uint16_t*)string; uint16_t* str = (uint16_t*)string;
std::vector<LLConstant*> vals; std::vector<LLConstant*> vals;
vals.reserve(len+1); vals.reserve(len+1);
for(size_t i=0; i<len; ++i) { for(size_t i=0; i<len; ++i) {
vals.push_back(gIR->context().getConstantInt(ct, str[i], false));; vals.push_back(LLConstantInt::get(ct, str[i], false));;
} }
vals.push_back(gIR->context().getConstantInt(ct, 0, false)); vals.push_back(LLConstantInt::get(ct, 0, false));
_init = llvm::ConstantArray::get(at,vals); _init = LLConstantArray::get(at,vals);
} }
else if (cty->size() == 4) { else if (cty->size() == 4) {
uint32_t* str = (uint32_t*)string; uint32_t* str = (uint32_t*)string;
std::vector<LLConstant*> vals; std::vector<LLConstant*> vals;
vals.reserve(len+1); vals.reserve(len+1);
for(size_t i=0; i<len; ++i) { for(size_t i=0; i<len; ++i) {
vals.push_back(gIR->context().getConstantInt(ct, str[i], false));; vals.push_back(LLConstantInt::get(ct, str[i], false));;
} }
vals.push_back(gIR->context().getConstantInt(ct, 0, false)); vals.push_back(LLConstantInt::get(ct, 0, false));
_init = llvm::ConstantArray::get(at,vals); _init = LLConstantArray::get(at,vals);
} }
else else
assert(0); assert(0);
@ -432,12 +432,12 @@ DValue* StringExp::toElem(IRState* p)
Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n'; Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n';
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(*gIR->module,at,true,_linkage,_init,".str"); llvm::GlobalVariable* gvar = new llvm::GlobalVariable(*gIR->module,at,true,_linkage,_init,".str");
llvm::ConstantInt* zero = gIR->context().getConstantInt(LLType::Int32Ty, 0, false); llvm::ConstantInt* zero = LLConstantInt::get(LLType::Int32Ty, 0, false);
LLConstant* idxs[2] = { zero, zero }; LLConstant* idxs[2] = { zero, zero };
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
if (dtype->ty == Tarray) { if (dtype->ty == Tarray) {
LLConstant* clen = gIR->context().getConstantInt(DtoSize_t(),len,false); LLConstant* clen = LLConstantInt::get(DtoSize_t(),len,false);
return new DImValue(type, DtoConstSlice(clen, arrptr)); return new DImValue(type, DtoConstSlice(clen, arrptr));
} }
else if (dtype->ty == Tsarray) { else if (dtype->ty == Tsarray) {
@ -473,29 +473,29 @@ LLConstant* StringExp::toConstElem(IRState* p)
if (cty->size() == 1) { if (cty->size() == 1) {
uint8_t* str = (uint8_t*)string; uint8_t* str = (uint8_t*)string;
std::string cont((char*)str, len); std::string cont((char*)str, len);
_init = gIR->context().getConstantArray(cont, nullterm); _init = LLConstantArray::get(cont, nullterm);
} }
else if (cty->size() == 2) { else if (cty->size() == 2) {
uint16_t* str = (uint16_t*)string; uint16_t* str = (uint16_t*)string;
std::vector<LLConstant*> vals; std::vector<LLConstant*> vals;
vals.reserve(len+1); vals.reserve(len+1);
for(size_t i=0; i<len; ++i) { for(size_t i=0; i<len; ++i) {
vals.push_back(gIR->context().getConstantInt(ct, str[i], false));; vals.push_back(LLConstantInt::get(ct, str[i], false));;
} }
if (nullterm) if (nullterm)
vals.push_back(gIR->context().getConstantInt(ct, 0, false)); vals.push_back(LLConstantInt::get(ct, 0, false));
_init = llvm::ConstantArray::get(at,vals); _init = LLConstantArray::get(at,vals);
} }
else if (cty->size() == 4) { else if (cty->size() == 4) {
uint32_t* str = (uint32_t*)string; uint32_t* str = (uint32_t*)string;
std::vector<LLConstant*> vals; std::vector<LLConstant*> vals;
vals.reserve(len+1); vals.reserve(len+1);
for(size_t i=0; i<len; ++i) { for(size_t i=0; i<len; ++i) {
vals.push_back(gIR->context().getConstantInt(ct, str[i], false));; vals.push_back(LLConstantInt::get(ct, str[i], false));;
} }
if (nullterm) if (nullterm)
vals.push_back(gIR->context().getConstantInt(ct, 0, false)); vals.push_back(LLConstantInt::get(ct, 0, false));
_init = llvm::ConstantArray::get(at,vals); _init = LLConstantArray::get(at,vals);
} }
else else
assert(0); assert(0);
@ -508,7 +508,7 @@ LLConstant* StringExp::toConstElem(IRState* p)
llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage; llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(*gIR->module,_init->getType(),true,_linkage,_init,".str"); llvm::GlobalVariable* gvar = new llvm::GlobalVariable(*gIR->module,_init->getType(),true,_linkage,_init,".str");
llvm::ConstantInt* zero = gIR->context().getConstantInt(LLType::Int32Ty, 0, false); llvm::ConstantInt* zero = LLConstantInt::get(LLType::Int32Ty, 0, false);
LLConstant* idxs[2] = { zero, zero }; LLConstant* idxs[2] = { zero, zero };
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
@ -516,7 +516,7 @@ LLConstant* StringExp::toConstElem(IRState* p)
return arrptr; return arrptr;
} }
else if (t->ty == Tarray) { else if (t->ty == Tarray) {
LLConstant* clen = gIR->context().getConstantInt(DtoSize_t(),len,false); LLConstant* clen = LLConstantInt::get(DtoSize_t(),len,false);
return DtoConstSlice(clen, arrptr); return DtoConstSlice(clen, arrptr);
} }
@ -1356,11 +1356,11 @@ DValue* CmpExp::toElem(IRState* p)
break; break;
case TOKleg: case TOKleg:
skip = true; skip = true;
eval = gIR->context().getConstantIntTrue(); eval = gIR->context().getTrue();
break; break;
case TOKunord: case TOKunord:
skip = true; skip = true;
eval = gIR->context().getConstantIntFalse(); eval = gIR->context().getFalse();
break; break;
default: default:
@ -1525,7 +1525,7 @@ DValue* PostExp::toElem(IRState* p)
if (e1type->isintegral()) if (e1type->isintegral())
{ {
assert(e2type->isintegral()); assert(e2type->isintegral());
LLValue* one = gIR->context().getConstantInt(val->getType(), 1, !e2type->isunsigned()); LLValue* one = LLConstantInt::get(val->getType(), 1, !e2type->isunsigned());
if (op == TOKplusplus) { if (op == TOKplusplus) {
post = llvm::BinaryOperator::CreateAdd(val,one,"tmp",p->scopebb()); post = llvm::BinaryOperator::CreateAdd(val,one,"tmp",p->scopebb());
} }
@ -1536,8 +1536,8 @@ DValue* PostExp::toElem(IRState* p)
else if (e1type->ty == Tpointer) else if (e1type->ty == Tpointer)
{ {
assert(e2type->isintegral()); assert(e2type->isintegral());
LLConstant* minusone = gIR->context().getConstantInt(DtoSize_t(),(uint64_t)-1,true); LLConstant* minusone = LLConstantInt::get(DtoSize_t(),(uint64_t)-1,true);
LLConstant* plusone = gIR->context().getConstantInt(DtoSize_t(),(uint64_t)1,false); LLConstant* plusone = LLConstantInt::get(DtoSize_t(),(uint64_t)1,false);
LLConstant* whichone = (op == TOKplusplus) ? plusone : minusone; LLConstant* whichone = (op == TOKplusplus) ? plusone : minusone;
post = llvm::GetElementPtrInst::Create(val, whichone, "tmp", p->scopebb()); post = llvm::GetElementPtrInst::Create(val, whichone, "tmp", p->scopebb());
} }
@ -1844,7 +1844,7 @@ DValue* AndAndExp::toElem(IRState* p)
llvm::PHINode* phi = p->ir->CreatePHI(LLType::Int1Ty, "andandval"); llvm::PHINode* phi = p->ir->CreatePHI(LLType::Int1Ty, "andandval");
// If we jumped over evaluation of the right-hand side, // If we jumped over evaluation of the right-hand side,
// the result is false. Otherwise it's the value of the right-hand side. // the result is false. Otherwise it's the value of the right-hand side.
phi->addIncoming(gIR->context().getConstantIntFalse(), oldblock); phi->addIncoming(gIR->context().getFalse(), oldblock);
phi->addIncoming(vbool, newblock); phi->addIncoming(vbool, newblock);
resval = phi; resval = phi;
} }
@ -1891,7 +1891,7 @@ DValue* OrOrExp::toElem(IRState* p)
llvm::PHINode* phi = p->ir->CreatePHI(LLType::Int1Ty, "ororval"); llvm::PHINode* phi = p->ir->CreatePHI(LLType::Int1Ty, "ororval");
// If we jumped over evaluation of the right-hand side, // If we jumped over evaluation of the right-hand side,
// the result is true. Otherwise, it's the value of the right-hand side. // the result is true. Otherwise, it's the value of the right-hand side.
phi->addIncoming(gIR->context().getConstantIntTrue(), oldblock); phi->addIncoming(gIR->context().getTrue(), oldblock);
phi->addIncoming(vbool, newblock); phi->addIncoming(vbool, newblock);
resval = phi; resval = phi;
} }
@ -2146,7 +2146,7 @@ DValue* ComExp::toElem(IRState* p)
DValue* u = e1->toElem(p); DValue* u = e1->toElem(p);
LLValue* value = u->getRVal(); LLValue* value = u->getRVal();
LLValue* minusone = gIR->context().getConstantInt(value->getType(), (uint64_t)-1, true); LLValue* minusone = LLConstantInt::get(value->getType(), (uint64_t)-1, true);
value = llvm::BinaryOperator::Create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb()); value = llvm::BinaryOperator::Create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb());
return new DImValue(type, value); return new DImValue(type, value);
@ -2376,7 +2376,7 @@ LLConstant* ArrayLiteralExp::toConstElem(IRState* p)
} }
// build the constant array initializer // build the constant array initializer
LLConstant* initval = llvm::ConstantArray::get(arrtype, vals); LLConstant* initval = LLConstantArray::get(arrtype, vals);
// if static array, we're done // if static array, we're done
if (!dyn) if (!dyn)
@ -2501,7 +2501,7 @@ LLConstant* StructLiteralExp::toConstElem(IRState* p)
constvals[i] = llvm::cast<LLConstant>(values[i]); constvals[i] = llvm::cast<LLConstant>(values[i]);
// return constant struct // return constant struct
return gIR->context().getConstantStruct(constvals, sd->ir.irStruct->packed); return LLConstantStruct::get(constvals, sd->ir.irStruct->packed);
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////

View file

@ -531,23 +531,23 @@ void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device)
llvm::ConstantInt* DtoConstSize_t(uint64_t i) llvm::ConstantInt* DtoConstSize_t(uint64_t i)
{ {
return gIR->context().getConstantInt(DtoSize_t(), i, false); return LLConstantInt::get(DtoSize_t(), i, false);
} }
llvm::ConstantInt* DtoConstUint(unsigned i) llvm::ConstantInt* DtoConstUint(unsigned i)
{ {
return gIR->context().getConstantInt(LLType::Int32Ty, i, false); return LLConstantInt::get(LLType::Int32Ty, i, false);
} }
llvm::ConstantInt* DtoConstInt(int i) llvm::ConstantInt* DtoConstInt(int i)
{ {
return gIR->context().getConstantInt(LLType::Int32Ty, i, true); return LLConstantInt::get(LLType::Int32Ty, i, true);
} }
LLConstant* DtoConstBool(bool b) LLConstant* DtoConstBool(bool b)
{ {
return gIR->context().getConstantInt(LLType::Int1Ty, b, false); return LLConstantInt::get(LLType::Int1Ty, b, false);
} }
llvm::ConstantInt* DtoConstUbyte(unsigned char i) llvm::ConstantInt* DtoConstUbyte(unsigned char i)
{ {
return gIR->context().getConstantInt(LLType::Int8Ty, i, false); return LLConstantInt::get(LLType::Int8Ty, i, false);
} }
LLConstant* DtoConstFP(Type* t, long double value) LLConstant* DtoConstFP(Type* t, long double value)
@ -556,12 +556,12 @@ LLConstant* DtoConstFP(Type* t, long double value)
assert(llty->isFloatingPoint()); assert(llty->isFloatingPoint());
if(llty == LLType::FloatTy || llty == LLType::DoubleTy) if(llty == LLType::FloatTy || llty == LLType::DoubleTy)
return gIR->context().getConstantFP(llty, value); return LLConstantFP::get(llty, value);
else if(llty == LLType::X86_FP80Ty) { else if(llty == LLType::X86_FP80Ty) {
uint64_t bits[] = {0, 0}; uint64_t bits[] = {0, 0};
bits[0] = *(uint64_t*)&value; bits[0] = *(uint64_t*)&value;
bits[1] = *(uint16_t*)((uint64_t*)&value + 1); bits[1] = *(uint16_t*)((uint64_t*)&value + 1);
return gIR->context().getConstantFP(APFloat(APInt(80, 2, bits))); return LLConstantFP::get(gIR->context(), APFloat(APInt(80, 2, bits)));
} else { } else {
assert(0 && "Unknown floating point type encountered"); assert(0 && "Unknown floating point type encountered");
} }
@ -572,7 +572,7 @@ LLConstant* DtoConstFP(Type* t, long double value)
LLConstant* DtoConstString(const char* str) LLConstant* DtoConstString(const char* str)
{ {
std::string s(str?str:""); std::string s(str?str:"");
LLConstant* init = gIR->context().getConstantArray(s, true); LLConstant* init = LLConstantArray::get(s, true);
llvm::GlobalVariable* gvar = new llvm::GlobalVariable( llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
*gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str"); *gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str");
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
@ -584,7 +584,7 @@ LLConstant* DtoConstString(const char* str)
LLConstant* DtoConstStringPtr(const char* str, const char* section) LLConstant* DtoConstStringPtr(const char* str, const char* section)
{ {
std::string s(str); std::string s(str);
LLConstant* init = gIR->context().getConstantArray(s, true); LLConstant* init = LLConstantArray::get(s, true);
llvm::GlobalVariable* gvar = new llvm::GlobalVariable( llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
*gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str"); *gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str");
if (section) gvar->setSection(section); if (section) gvar->setSection(section);

View file

@ -674,7 +674,7 @@ void Module::genmoduleinfo()
if (!importInits.empty()) if (!importInits.empty())
{ {
const llvm::ArrayType* importArrTy = llvm::ArrayType::get(getPtrToType(moduleinfoTy), importInits.size()); const llvm::ArrayType* importArrTy = llvm::ArrayType::get(getPtrToType(moduleinfoTy), importInits.size());
c = llvm::ConstantArray::get(importArrTy, importInits); c = LLConstantArray::get(importArrTy, importInits);
std::string m_name("_D"); std::string m_name("_D");
m_name.append(mangle()); m_name.append(mangle());
m_name.append("9__importsZ"); m_name.append("9__importsZ");
@ -725,7 +725,7 @@ void Module::genmoduleinfo()
if (!classInits.empty()) if (!classInits.empty())
{ {
const llvm::ArrayType* classArrTy = llvm::ArrayType::get(getPtrToType(classinfoTy), classInits.size()); const llvm::ArrayType* classArrTy = llvm::ArrayType::get(getPtrToType(classinfoTy), classInits.size());
c = llvm::ConstantArray::get(classArrTy, classInits); c = LLConstantArray::get(classArrTy, classInits);
std::string m_name("_D"); std::string m_name("_D");
m_name.append(mangle()); m_name.append(mangle());
m_name.append("9__classesZ"); m_name.append("9__classesZ");
@ -819,7 +819,7 @@ void Module::genmoduleinfo()
// declare the appending array // declare the appending array
const llvm::ArrayType* appendArrTy = llvm::ArrayType::get(magicsty, 1); const llvm::ArrayType* appendArrTy = llvm::ArrayType::get(magicsty, 1);
std::vector<LLConstant*> appendInits(1, magicinit); std::vector<LLConstant*> appendInits(1, magicinit);
LLConstant* appendInit = llvm::ConstantArray::get(appendArrTy, appendInits); LLConstant* appendInit = LLConstantArray::get(appendArrTy, appendInits);
std::string appendName("llvm.global_ctors"); std::string appendName("llvm.global_ctors");
llvm::GlobalVariable* appendVar = new llvm::GlobalVariable(*gIR->module, appendArrTy, true, llvm::GlobalValue::AppendingLinkage, appendInit, appendName); llvm::GlobalVariable* appendVar = new llvm::GlobalVariable(*gIR->module, appendArrTy, true, llvm::GlobalValue::AppendingLinkage, appendInit, appendName);
} }

View file

@ -433,9 +433,9 @@ void TypeInfoEnumDeclaration::llvmDefine()
{ {
const LLType* memty = DtoType(sd->memtype); const LLType* memty = DtoType(sd->memtype);
#if DMDV2 #if DMDV2
LLConstant* C = gIR->context().getConstantInt(memty, sd->defaultval->toInteger(), !sd->memtype->isunsigned()); LLConstant* C = LLConstantInt::get(memty, sd->defaultval->toInteger(), !sd->memtype->isunsigned());
#else #else
LLConstant* C = gIR->context().getConstantInt(memty, sd->defaultval, !sd->memtype->isunsigned()); LLConstant* C = LLConstantInt::get(memty, sd->defaultval, !sd->memtype->isunsigned());
#endif #endif
b.push_void_array(C, sd->memtype, sd); b.push_void_array(C, sd->memtype, sd);
} }
@ -734,7 +734,7 @@ void TypeInfoTupleDeclaration::llvmDefine()
// build array // build array
const LLArrayType* arrTy = LLArrayType::get(tiTy, dim); const LLArrayType* arrTy = LLArrayType::get(tiTy, dim);
LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits); LLConstant* arrC = LLConstantArray::get(arrTy, arrInits);
RTTIBuilder b(Type::typeinfotypelist); RTTIBuilder b(Type::typeinfotypelist);

View file

@ -82,8 +82,8 @@ LLGlobalVariable * IrStruct::getClassInfoSymbol()
// Construct the fields // Construct the fields
MDNodeField* mdVals[CD_NumFields]; MDNodeField* mdVals[CD_NumFields];
mdVals[CD_BodyType] = llvm::UndefValue::get(bodyType); mdVals[CD_BodyType] = llvm::UndefValue::get(bodyType);
mdVals[CD_Finalize] = gIR->context().getConstantInt(LLType::Int1Ty, hasDestructor); mdVals[CD_Finalize] = LLConstantInt::get(LLType::Int1Ty, hasDestructor);
mdVals[CD_CustomDelete] = gIR->context().getConstantInt(LLType::Int1Ty, hasCustomDelete); mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::Int1Ty, hasCustomDelete);
// Construct the metadata // Construct the metadata
llvm::MDNode* metadata = gIR->context().getMDNode(mdVals, CD_NumFields); llvm::MDNode* metadata = gIR->context().getMDNode(mdVals, CD_NumFields);
// Insert it into the module // Insert it into the module
@ -170,7 +170,7 @@ LLConstant * IrStruct::getVtblInit()
} }
// build the constant struct // build the constant struct
constVtbl = gIR->context().getConstantStruct(constants, false); constVtbl = LLConstantStruct::get(constants, false);
#if 0 #if 0
IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl; IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl;
@ -314,7 +314,7 @@ LLConstant * IrStruct::createClassDefaultInitializer()
addBaseClassInits(constants, cd, offset, field_index); addBaseClassInits(constants, cd, offset, field_index);
// build the constant // build the constant
llvm::Constant* definit = gIR->context().getConstantStruct(constants, false); llvm::Constant* definit = LLConstantStruct::get(constants, false);
return definit; return definit;
} }
@ -382,7 +382,7 @@ llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instan
} }
// build the vtbl constant // build the vtbl constant
llvm::Constant* vtbl_constant = gIR->context().getConstantStruct(constants, false); llvm::Constant* vtbl_constant = LLConstantStruct::get(constants, false);
// create the global variable to hold it // create the global variable to hold it
llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl); llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl);
@ -481,7 +481,7 @@ LLConstant * IrStruct::getClassInfoInterfaces()
// create Interface struct // create Interface struct
LLConstant* inits[3] = { ci, vtb, off }; LLConstant* inits[3] = { ci, vtb, off };
LLConstant* entry = gIR->context().getConstantStruct(inits, 3); LLConstant* entry = LLConstantStruct::get(inits, 3);
constants.push_back(entry); constants.push_back(entry);
} }
@ -490,7 +490,7 @@ LLConstant * IrStruct::getClassInfoInterfaces()
constants[0]->getType(), constants[0]->getType(),
n); n);
LLConstant* arr = gIR->context().getConstantArray( LLConstant* arr = LLConstantArray::get(
array_type, array_type,
&constants[0], &constants[0],
n); n);

View file

@ -133,7 +133,7 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB)
} }
// if there's a finally, the eh table has to have a 0 action // if there's a finally, the eh table has to have a 0 action
if(hasFinally) if(hasFinally)
selectorargs.push_back(gIR->context().getConstantInt(LLType::Int32Ty, 0)); selectorargs.push_back(LLConstantInt::get(LLType::Int32Ty, 0));
// personality fn // personality fn
llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_personality"); llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_personality");
@ -186,7 +186,7 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB)
} }
// dubious comment // dubious comment
// catches matched first get the largest switchval, so do size - unique int // catches matched first get the largest switchval, so do size - unique int
llvm::ConstantInt* switchval = gIR->context().getConstantInt(DtoSize_t(), catchToInt[rit->catchType]); llvm::ConstantInt* switchval = LLConstantInt::get(DtoSize_t(), catchToInt[rit->catchType]);
// and make sure we don't add the same switchval twice, may happen with nested trys // and make sure we don't add the same switchval twice, may happen with nested trys
if(!switchinst->findCaseValue(switchval)) if(!switchinst->findCaseValue(switchval))
switchinst->addCase(switchval, rit->target); switchinst->addCase(switchval, rit->target);

View file

@ -195,7 +195,7 @@ LLConstant * IrStruct::createStructDefaultInitializer()
} }
// build constant struct // build constant struct
llvm::Constant* definit = gIR->context().getConstantStruct(constants, packed); llvm::Constant* definit = LLConstantStruct::get(constants, packed);
#if 0 #if 0
IF_LOG Logger::cout() << "final default initializer: " << *definit << std::endl; IF_LOG Logger::cout() << "final default initializer: " << *definit << std::endl;
#endif #endif
@ -384,7 +384,7 @@ LLConstant * IrStruct::createStructInitializer(StructInitializer * si)
// build constant // build constant
assert(!constants.empty()); assert(!constants.empty());
llvm::Constant* c = gIR->context().getConstantStruct(&constants[0], constants.size(), packed); llvm::Constant* c = LLConstantStruct::get(&constants[0], constants.size(), packed);
IF_LOG Logger::cout() << "final struct initializer: " << *c << std::endl; IF_LOG Logger::cout() << "final struct initializer: " << *c << std::endl;
return c; return c;
} }