# HG changeset patch # User Benjamin Kramer # Date 1248960310 -7200 # Node ID d6e8d5db259f80739fb7d9dfdfa402a8822288af # Parent f55ca8a1598cd2de26579584342a17cf10978b55 LLVMContext changes up to r77366 diff -r f55ca8a1598c -r d6e8d5db259f gen/abi.cpp --- a/gen/abi.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/abi.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -60,7 +60,7 @@ rpart = gIR->ir->CreateBitCast(rpart, LLType::FloatTy, ".re"); // 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->CreateBitCast(ipart, LLType::FloatTy, ".im"); @@ -87,7 +87,7 @@ // zext to i64 i = gIR->ir->CreateZExt(i, LLType::Int64Ty); // 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 return v = gIR->ir->CreateOr(r, i); diff -r f55ca8a1598c -r d6e8d5db259f gen/arrays.cpp --- a/gen/arrays.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/arrays.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -309,7 +309,7 @@ LLConstant* constarr; if (mismatch) - constarr = gIR->context().getConstantStruct(initvals); + constarr = LLConstantStruct::get(initvals); else constarr = LLConstantArray::get(LLArrayType::get(llelemty, arrlen), initvals); @@ -394,7 +394,7 @@ LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr) { LLConstant* values[2] = { dim, ptr }; - return gIR->context().getConstantStruct(values, 2); + return LLConstantStruct::get(values, 2); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -784,11 +784,11 @@ break; case TOKleg: skip = true; - res = gIR->context().getConstantIntTrue(); + res = gIR->context().getTrue(); break; case TOKunord: skip = true; - res = gIR->context().getConstantIntFalse(); + res = gIR->context().getFalse(); break; default: @@ -826,8 +826,8 @@ LLSmallVector args; args.push_back(len); - args.push_back(gIR->context().getConstantInt(DtoSize_t(), esz, false)); - args.push_back(gIR->context().getConstantInt(DtoSize_t(), nsz, false)); + args.push_back(LLConstantInt::get(DtoSize_t(), esz, false)); + args.push_back(LLConstantInt::get(DtoSize_t(), nsz, false)); LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len"); return gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), "tmp").getInstruction(); @@ -962,7 +962,7 @@ 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()) rval2 = DtoArrayCastLength(rval2, ety, ptrty->getContainedType(0)); rval = DtoBitCast(uval, ptrty); diff -r f55ca8a1598c -r d6e8d5db259f gen/asmstmt.cpp --- a/gen/asmstmt.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/asmstmt.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -769,7 +769,7 @@ for(it = gotoToVal.begin(); it != end; ++it) { 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); DtoGoto(loc, it->first, enclosingFinally); diff -r f55ca8a1598c -r d6e8d5db259f gen/classes.cpp --- a/gen/classes.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/classes.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -606,7 +606,7 @@ // array type 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 std::string name(cd->type->vtinfo->toChars()); diff -r f55ca8a1598c -r d6e8d5db259f gen/llvmhelpers.cpp --- a/gen/llvmhelpers.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/llvmhelpers.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -514,7 +514,7 @@ } 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"); } else if (to->isintegral()) { diff -r f55ca8a1598c -r d6e8d5db259f gen/passes/GarbageCollect2Stack.cpp --- a/gen/passes/GarbageCollect2Stack.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/passes/GarbageCollect2Stack.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -58,24 +58,24 @@ // Helper functions //===----------------------------------------------------------------------===// -void EmitMemSet(LLVMContext& Context, IRBuilder<>& B, Value* Dst, Value* Val, - Value* Len, const Analysis& A) { +void EmitMemSet(IRBuilder<>& B, Value* Dst, Value* Val, Value* Len, + const Analysis& A) { Dst = B.CreateBitCast(Dst, PointerType::getUnqual(Type::Int8Ty)); 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 = Context.getConstantInt(Type::Int32Ty, 1); + Value *Align = ConstantInt::get(Type::Int32Ty, 1); CallSite CS = B.CreateCall4(MemSet, Dst, Val, Len, Align); if (A.CGNode) A.CGNode->addCalledFunction(CS, A.CG->getOrInsertFunction(MemSet)); } -static void EmitMemZero(LLVMContext& Context, IRBuilder<>& B, Value* Dst, - Value* Len, const Analysis& A) { - EmitMemSet(Context, B, Dst, Context.getConstantInt(Type::Int8Ty, 0), Len, A); +static void EmitMemZero(IRBuilder<>& B, Value* Dst, Value* Len, + const Analysis& A) { + EmitMemSet(B, Dst, ConstantInt::get(Type::Int8Ty, 0), Len, A); } @@ -94,7 +94,7 @@ // Analyze the current call, filling in some fields. Returns true if // 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); Ty = A.getTypeFor(TypeInfo); return (Ty != NULL); @@ -102,7 +102,7 @@ // Returns the alloca to replace this 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++; Instruction* Begin = CS.getCaller()->getEntryBlock().begin(); @@ -119,15 +119,15 @@ bool Initialized; public: - ArrayFI(unsigned tiArgNr, bool safeToDelete, - bool initialized, unsigned arrSizeArgNr) + ArrayFI(unsigned tiArgNr, bool safeToDelete, bool initialized, + unsigned arrSizeArgNr) : FunctionInfo(tiArgNr, safeToDelete), ArrSizeArgNr(arrSizeArgNr), Initialized(initialized) {} - virtual bool analyze(LLVMContext& context, CallSite CS, const Analysis& A) { - if (!FunctionInfo::analyze(context, CS, A)) + virtual bool analyze(CallSite CS, const Analysis& A) { + if (!FunctionInfo::analyze(CS, A)) return false; arrSize = CS.getArgument(ArrSizeArgNr); @@ -155,7 +155,7 @@ 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; // 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. @@ -178,11 +178,11 @@ if (Initialized) { // For now, only zero-init is supported. 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 // allocation site. Value* Size = B.CreateMul(TypeSize, arrSize); - EmitMemZero(context, B, alloca, Size, A); + EmitMemZero(B, alloca, Size, A); } return alloca; @@ -192,7 +192,7 @@ // FunctionInfo for _d_allocclass class AllocClassFI : public FunctionInfo { 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 // base class implementation here... if (CS.arg_size() != 1) @@ -223,8 +223,8 @@ if (hasDestructor == NULL || hasCustomDelete == NULL) return false; - if (context.getConstantExprOr(hasDestructor, hasCustomDelete) - != context.getConstantIntFalse()) + if (ConstantExpr::getOr(hasDestructor, hasCustomDelete) + != A.M.getContext().getFalse()) return false; Ty = MD_GetElement(node, CD_BodyType)->getType(); @@ -259,7 +259,6 @@ GarbageCollect2Stack(); bool doInitialization(Module &M) { - Context = &M.getContext(); this->M = &M; return false; } @@ -297,7 +296,7 @@ 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()) { InvokeInst* Invoke = cast(CS.getInstruction()); // If this was an invoke instruction, we need to do some extra @@ -306,7 +305,7 @@ // Create a "conditional" branch that -simplifycfg can clean up, so we // can keep using the DominatorTree without updating it. BranchInst::Create(Invoke->getNormalDest(), Invoke->getUnwindDest(), - context.getConstantIntTrue(), Invoke->getParent()); + A.M.getContext().getTrue(), Invoke->getParent()); } // Remove the runtime call. if (A.CGNode) @@ -360,20 +359,20 @@ if (Inst->use_empty() && info->SafeToDelete) { Changed = true; NumDeleted++; - RemoveCall(*Context, CS, A); + RemoveCall(CS, A); continue; } DEBUG(errs() << "GarbageCollect2Stack inspecting: " << *Inst); - if (!info->analyze(*Context, CS, A) || !isSafeToStackAllocate(Inst, DT)) + if (!info->analyze(CS, A) || !isSafeToStackAllocate(Inst, DT)) continue; // Let's alloca this! Changed = true; IRBuilder<> Builder(BB, Inst); - Value* newVal = info->promote(*Context, CS, Builder, A); + Value* newVal = info->promote(CS, Builder, A); DEBUG(errs() << "Promoted to: " << *newVal); @@ -383,7 +382,7 @@ newVal = Builder.CreateBitCast(newVal, Inst->getType()); Inst->replaceAllUsesWith(newVal); - RemoveCall(*Context, CS, A); + RemoveCall(CS, A); } } diff -r f55ca8a1598c -r d6e8d5db259f gen/passes/SimplifyDRuntimeCalls.cpp --- a/gen/passes/SimplifyDRuntimeCalls.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/passes/SimplifyDRuntimeCalls.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -74,7 +74,7 @@ this->TD = &TD; this->AA = &AA; if (CI->getCalledFunction()) - Context = CI->getCalledFunction()->getContext(); + Context = &CI->getCalledFunction()->getContext(); return CallOptimizer(CI->getCalledFunction(), CI, B); } }; @@ -95,7 +95,7 @@ Tys[0] = Len->getType(); Value *MemCpy = Intrinsic::getDeclaration(M, IID, Tys, 1); 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 @@ APInt Quot, Rem; APInt::udivrem(OldInt->getValue(), NewInt->getValue(), Quot, Rem); if (Rem == 0) - return B.CreateMul(OldLen, Context->getConstantInt(Quot)); + return B.CreateMul(OldLen, ConstantInt::get(*Context, Quot)); } return 0; } @@ -202,7 +202,7 @@ Constant* C = 0; if ((C = dyn_cast(Cmp->getOperand(0))) || (C = dyn_cast(Cmp->getOperand(1)))) { - Value* Result = Context->getConstantInt(Type::Int1Ty, !Cmp->isTrueWhenEqual()); + Value* Result = ConstantInt::get(Type::Int1Ty, !Cmp->isTrueWhenEqual()); Cmp->replaceAllUsesWith(Result); // Don't delete the comparison because there may be an // iterator to it. Instead, set the operands to constants @@ -359,8 +359,8 @@ } bool SimplifyDRuntimeCalls::runOnce(Function &F, const TargetData& TD, AliasAnalysis& AA) { - IRBuilder<> Builder(*Context); - + IRBuilder<> Builder(F.getContext()); + bool Changed = false; for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) { diff -r f55ca8a1598c -r d6e8d5db259f gen/rttibuilder.cpp --- a/gen/rttibuilder.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/rttibuilder.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -142,7 +142,7 @@ void RTTIBuilder::finalize(IrGlobal* tid) { // 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 llvm::cast(tid->type.get())->refineAbstractTypeTo(tiInit->getType()); @@ -154,5 +154,5 @@ LLConstant* RTTIBuilder::get_constant() { // just return the inititalizer - return gIR->context().getConstantStruct(&inits[0], inits.size(), false); + return LLConstantStruct::get(&inits[0], inits.size(), false); } diff -r f55ca8a1598c -r d6e8d5db259f gen/statements.cpp --- a/gen/statements.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/statements.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -815,7 +815,7 @@ // build static array for ptr or final array const LLType* elemTy = DtoType(condition->type); 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"); const LLType* elemPtrTy = getPtrToType(elemTy); @@ -1030,7 +1030,7 @@ keyvar = DtoRawVarDeclaration(key); else keyvar = DtoRawAlloca(keytype, 0, "foreachkey"); // FIXME: align? - LLValue* zerokey = gIR->context().getConstantInt(keytype,0,false); + LLValue* zerokey = LLConstantInt::get(keytype,0,false); // value Logger::println("value = %s", value->toPrettyChars()); @@ -1087,7 +1087,7 @@ } else if (op == TOKforeach_reverse) { 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); } llvm::BranchInst::Create(bodybb, endbb, done, p->scopebb()); @@ -1096,7 +1096,7 @@ p->scope() = IRScope(bodybb,nextbb); // 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* gep = DtoGEP1(val,loadedKey); @@ -1124,7 +1124,7 @@ p->scope() = IRScope(nextbb,endbb); if (op == TOKforeach) { 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); } llvm::BranchInst::Create(condbb, p->scopebb()); diff -r f55ca8a1598c -r d6e8d5db259f gen/structs.cpp --- a/gen/structs.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/structs.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -108,7 +108,7 @@ // call memcmp size_t sz = getTypePaddedSize(DtoType(t)); 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"); } ////////////////////////////////////////////////////////////////////////////////////////// diff -r f55ca8a1598c -r d6e8d5db259f gen/tocall.cpp --- a/gen/tocall.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/tocall.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -199,7 +199,7 @@ } // apply initializer - LLConstant* tiinits = llvm::ConstantArray::get(typeinfoarraytype, vtypeinfos); + LLConstant* tiinits = LLConstantArray::get(typeinfoarraytype, vtypeinfos); typeinfomem->setInitializer(tiinits); // put data in d-array @@ -207,7 +207,7 @@ pinits.push_back(DtoConstSize_t(vtype->getNumElements())); pinits.push_back(llvm::ConstantExpr::getBitCast(typeinfomem, getPtrToType(typeinfotype))); 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, true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array"); diff -r f55ca8a1598c -r d6e8d5db259f gen/todebug.cpp --- a/gen/todebug.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/todebug.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -23,7 +23,7 @@ #define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) ) #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 @@ vals[4] = DtoConstInt(linnum); // 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 - vals[6] = gIR->context().getConstantInt(LLType::Int64Ty, getABITypeAlign(T)*8, false); + vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false); // 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 vals[8] = DtoConstUint(0); diff -r f55ca8a1598c -r d6e8d5db259f gen/toir.cpp --- a/gen/toir.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/toir.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -288,11 +288,11 @@ const LLType* t = DtoType(type); if (isaPointer(t)) { 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); } assert(llvm::isa(t)); - LLConstant* c = gIR->context().getConstantInt(t,(uint64_t)value,!type->isunsigned()); + LLConstant* c = LLConstantInt::get(t,(uint64_t)value,!type->isunsigned()); assert(c); if (Logger::enabled()) Logger::cout() << "value = " << *c << '\n'; @@ -338,7 +338,7 @@ const LLType* t = DtoType(type); if (type->ty == Tarray) { assert(isaStruct(t)); - return llvm::ConstantAggregateZero::get(t); + return gIR->context().getConstantAggregateZero(t); } else { return gIR->context().getNullValue(t); @@ -402,27 +402,27 @@ if (cty->size() == 1) { uint8_t* str = (uint8_t*)string; std::string cont((char*)str, len); - _init = gIR->context().getConstantArray(cont,true); + _init = LLConstantArray::get(cont,true); } else if (cty->size() == 2) { uint16_t* str = (uint16_t*)string; std::vector vals; vals.reserve(len+1); for(size_t i=0; icontext().getConstantInt(ct, str[i], false));; + vals.push_back(LLConstantInt::get(ct, str[i], false));; } - vals.push_back(gIR->context().getConstantInt(ct, 0, false)); - _init = llvm::ConstantArray::get(at,vals); + vals.push_back(LLConstantInt::get(ct, 0, false)); + _init = LLConstantArray::get(at,vals); } else if (cty->size() == 4) { uint32_t* str = (uint32_t*)string; std::vector vals; vals.reserve(len+1); for(size_t i=0; icontext().getConstantInt(ct, str[i], false));; + vals.push_back(LLConstantInt::get(ct, str[i], false));; } - vals.push_back(gIR->context().getConstantInt(ct, 0, false)); - _init = llvm::ConstantArray::get(at,vals); + vals.push_back(LLConstantInt::get(ct, 0, false)); + _init = LLConstantArray::get(at,vals); } else assert(0); @@ -432,12 +432,12 @@ Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n'; 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* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); 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)); } else if (dtype->ty == Tsarray) { @@ -473,29 +473,29 @@ if (cty->size() == 1) { uint8_t* str = (uint8_t*)string; std::string cont((char*)str, len); - _init = gIR->context().getConstantArray(cont, nullterm); + _init = LLConstantArray::get(cont, nullterm); } else if (cty->size() == 2) { uint16_t* str = (uint16_t*)string; std::vector vals; vals.reserve(len+1); for(size_t i=0; icontext().getConstantInt(ct, str[i], false));; + vals.push_back(LLConstantInt::get(ct, str[i], false));; } if (nullterm) - vals.push_back(gIR->context().getConstantInt(ct, 0, false)); - _init = llvm::ConstantArray::get(at,vals); + vals.push_back(LLConstantInt::get(ct, 0, false)); + _init = LLConstantArray::get(at,vals); } else if (cty->size() == 4) { uint32_t* str = (uint32_t*)string; std::vector vals; vals.reserve(len+1); for(size_t i=0; icontext().getConstantInt(ct, str[i], false));; + vals.push_back(LLConstantInt::get(ct, str[i], false));; } if (nullterm) - vals.push_back(gIR->context().getConstantInt(ct, 0, false)); - _init = llvm::ConstantArray::get(at,vals); + vals.push_back(LLConstantInt::get(ct, 0, false)); + _init = LLConstantArray::get(at,vals); } else assert(0); @@ -508,7 +508,7 @@ llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage; 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* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); @@ -516,7 +516,7 @@ return arrptr; } 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); } @@ -1356,11 +1356,11 @@ break; case TOKleg: skip = true; - eval = gIR->context().getConstantIntTrue(); + eval = gIR->context().getTrue(); break; case TOKunord: skip = true; - eval = gIR->context().getConstantIntFalse(); + eval = gIR->context().getFalse(); break; default: @@ -1525,7 +1525,7 @@ if (e1type->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) { post = llvm::BinaryOperator::CreateAdd(val,one,"tmp",p->scopebb()); } @@ -1536,8 +1536,8 @@ else if (e1type->ty == Tpointer) { assert(e2type->isintegral()); - LLConstant* minusone = gIR->context().getConstantInt(DtoSize_t(),(uint64_t)-1,true); - LLConstant* plusone = gIR->context().getConstantInt(DtoSize_t(),(uint64_t)1,false); + LLConstant* minusone = LLConstantInt::get(DtoSize_t(),(uint64_t)-1,true); + LLConstant* plusone = LLConstantInt::get(DtoSize_t(),(uint64_t)1,false); LLConstant* whichone = (op == TOKplusplus) ? plusone : minusone; post = llvm::GetElementPtrInst::Create(val, whichone, "tmp", p->scopebb()); } @@ -1844,7 +1844,7 @@ llvm::PHINode* phi = p->ir->CreatePHI(LLType::Int1Ty, "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(gIR->context().getConstantIntFalse(), oldblock); + phi->addIncoming(gIR->context().getFalse(), oldblock); phi->addIncoming(vbool, newblock); resval = phi; } @@ -1891,7 +1891,7 @@ llvm::PHINode* phi = p->ir->CreatePHI(LLType::Int1Ty, "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(gIR->context().getConstantIntTrue(), oldblock); + phi->addIncoming(gIR->context().getTrue(), oldblock); phi->addIncoming(vbool, newblock); resval = phi; } @@ -2146,7 +2146,7 @@ DValue* u = e1->toElem(p); 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()); return new DImValue(type, value); @@ -2376,7 +2376,7 @@ } // 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 (!dyn) @@ -2501,7 +2501,7 @@ constvals[i] = llvm::cast(values[i]); // return constant struct - return gIR->context().getConstantStruct(constvals, sd->ir.irStruct->packed); + return LLConstantStruct::get(constvals, sd->ir.irStruct->packed); } ////////////////////////////////////////////////////////////////////////////////////////// diff -r f55ca8a1598c -r d6e8d5db259f gen/tollvm.cpp --- a/gen/tollvm.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/tollvm.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -531,23 +531,23 @@ 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) { - return gIR->context().getConstantInt(LLType::Int32Ty, i, false); + return LLConstantInt::get(LLType::Int32Ty, i, false); } llvm::ConstantInt* DtoConstInt(int i) { - return gIR->context().getConstantInt(LLType::Int32Ty, i, true); + return LLConstantInt::get(LLType::Int32Ty, i, true); } 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) { - return gIR->context().getConstantInt(LLType::Int8Ty, i, false); + return LLConstantInt::get(LLType::Int8Ty, i, false); } LLConstant* DtoConstFP(Type* t, long double value) @@ -556,12 +556,12 @@ assert(llty->isFloatingPoint()); if(llty == LLType::FloatTy || llty == LLType::DoubleTy) - return gIR->context().getConstantFP(llty, value); + return LLConstantFP::get(llty, value); else if(llty == LLType::X86_FP80Ty) { uint64_t bits[] = {0, 0}; bits[0] = *(uint64_t*)&value; 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 { assert(0 && "Unknown floating point type encountered"); } @@ -572,7 +572,7 @@ LLConstant* DtoConstString(const char* 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( *gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str"); LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; @@ -584,7 +584,7 @@ LLConstant* DtoConstStringPtr(const char* str, const char* section) { std::string s(str); - LLConstant* init = gIR->context().getConstantArray(s, true); + LLConstant* init = LLConstantArray::get(s, true); llvm::GlobalVariable* gvar = new llvm::GlobalVariable( *gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str"); if (section) gvar->setSection(section); diff -r f55ca8a1598c -r d6e8d5db259f gen/toobj.cpp --- a/gen/toobj.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/toobj.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -674,7 +674,7 @@ if (!importInits.empty()) { 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"); m_name.append(mangle()); m_name.append("9__importsZ"); @@ -725,7 +725,7 @@ if (!classInits.empty()) { 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"); m_name.append(mangle()); m_name.append("9__classesZ"); @@ -819,7 +819,7 @@ // declare the appending array const llvm::ArrayType* appendArrTy = llvm::ArrayType::get(magicsty, 1); std::vector appendInits(1, magicinit); - LLConstant* appendInit = llvm::ConstantArray::get(appendArrTy, appendInits); + LLConstant* appendInit = LLConstantArray::get(appendArrTy, appendInits); std::string appendName("llvm.global_ctors"); llvm::GlobalVariable* appendVar = new llvm::GlobalVariable(*gIR->module, appendArrTy, true, llvm::GlobalValue::AppendingLinkage, appendInit, appendName); } diff -r f55ca8a1598c -r d6e8d5db259f gen/typinf.cpp --- a/gen/typinf.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/gen/typinf.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -433,9 +433,9 @@ { const LLType* memty = DtoType(sd->memtype); #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 - LLConstant* C = gIR->context().getConstantInt(memty, sd->defaultval, !sd->memtype->isunsigned()); + LLConstant* C = LLConstantInt::get(memty, sd->defaultval, !sd->memtype->isunsigned()); #endif b.push_void_array(C, sd->memtype, sd); } @@ -734,7 +734,7 @@ // build array const LLArrayType* arrTy = LLArrayType::get(tiTy, dim); - LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits); + LLConstant* arrC = LLConstantArray::get(arrTy, arrInits); RTTIBuilder b(Type::typeinfotypelist); diff -r f55ca8a1598c -r d6e8d5db259f ir/irclass.cpp --- a/ir/irclass.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/ir/irclass.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -82,8 +82,8 @@ // Construct the fields MDNodeField* mdVals[CD_NumFields]; mdVals[CD_BodyType] = llvm::UndefValue::get(bodyType); - mdVals[CD_Finalize] = gIR->context().getConstantInt(LLType::Int1Ty, hasDestructor); - mdVals[CD_CustomDelete] = gIR->context().getConstantInt(LLType::Int1Ty, hasCustomDelete); + mdVals[CD_Finalize] = LLConstantInt::get(LLType::Int1Ty, hasDestructor); + mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::Int1Ty, hasCustomDelete); // Construct the metadata llvm::MDNode* metadata = gIR->context().getMDNode(mdVals, CD_NumFields); // Insert it into the module @@ -170,7 +170,7 @@ } // build the constant struct - constVtbl = gIR->context().getConstantStruct(constants, false); + constVtbl = LLConstantStruct::get(constants, false); #if 0 IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl; @@ -314,7 +314,7 @@ addBaseClassInits(constants, cd, offset, field_index); // build the constant - llvm::Constant* definit = gIR->context().getConstantStruct(constants, false); + llvm::Constant* definit = LLConstantStruct::get(constants, false); return definit; } @@ -382,7 +382,7 @@ } // 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 llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl); @@ -481,7 +481,7 @@ // create Interface struct LLConstant* inits[3] = { ci, vtb, off }; - LLConstant* entry = gIR->context().getConstantStruct(inits, 3); + LLConstant* entry = LLConstantStruct::get(inits, 3); constants.push_back(entry); } @@ -490,7 +490,7 @@ constants[0]->getType(), n); - LLConstant* arr = gIR->context().getConstantArray( + LLConstant* arr = LLConstantArray::get( array_type, &constants[0], n); diff -r f55ca8a1598c -r d6e8d5db259f ir/irlandingpad.cpp --- a/ir/irlandingpad.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/ir/irlandingpad.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -133,7 +133,7 @@ } // if there's a finally, the eh table has to have a 0 action if(hasFinally) - selectorargs.push_back(gIR->context().getConstantInt(LLType::Int32Ty, 0)); + selectorargs.push_back(LLConstantInt::get(LLType::Int32Ty, 0)); // personality fn llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_personality"); @@ -186,7 +186,7 @@ } // dubious comment // 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 if(!switchinst->findCaseValue(switchval)) switchinst->addCase(switchval, rit->target); diff -r f55ca8a1598c -r d6e8d5db259f ir/irstruct.cpp --- a/ir/irstruct.cpp Thu Jul 23 20:34:35 2009 +0200 +++ b/ir/irstruct.cpp Thu Jul 30 15:25:10 2009 +0200 @@ -195,7 +195,7 @@ } // build constant struct - llvm::Constant* definit = gIR->context().getConstantStruct(constants, packed); + llvm::Constant* definit = LLConstantStruct::get(constants, packed); #if 0 IF_LOG Logger::cout() << "final default initializer: " << *definit << std::endl; #endif @@ -384,7 +384,7 @@ // build constant 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; return c; }