# HG changeset patch # User Benjamin Kramer # Date 1250203158 -7200 # Node ID 8d086d552909089df087a3937f0b9d2c1590edf8 # Parent ab03cfb3a2129fe1f5b18d0d8fff41519f038ad2 IntegerType is now contextifed. Requires llvm >= 78969. resistor says this will be the last context API change :) diff -r ab03cfb3a212 -r 8d086d552909 gen/aa.cpp --- a/gen/aa.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/aa.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -102,8 +102,8 @@ // 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"); diff -r ab03cfb3a212 -r 8d086d552909 gen/abi-x86-64.cpp --- a/gen/abi-x86-64.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/abi-x86-64.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -231,19 +231,19 @@ 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::X86_FP80Ty); + return const_cast(LLType::getX86_FP80Ty(gIR->context())); default: assert(0 && "Unanticipated argument class"); @@ -260,11 +260,11 @@ 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 @@ // 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; diff -r ab03cfb3a212 -r 8d086d552909 gen/abi.cpp --- a/gen/abi.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/abi.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -56,13 +56,13 @@ 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 @@ // 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 @@ // {float,float} -> i64 const LLType* type(Type*, const LLType* t) { - return LLType::Int64Ty; + return LLType::getInt64Ty(gIR->context()); } }; @@ -131,13 +131,13 @@ 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 @@ if (tf->next->toBasetype() == Type::tcomplex32) { fty.ret->rewrite = &cfloatToInt; - fty.ret->ltype = LLType::Int64Ty; + fty.ret->ltype = LLType::getInt64Ty(gIR->context()); } // IMPLICIT PARAMETERS diff -r ab03cfb3a212 -r 8d086d552909 gen/arrays.cpp --- a/gen/arrays.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/arrays.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -24,8 +24,8 @@ { 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 @@ 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 @@ 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 @@ LLSmallVector 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 @@ // 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"); diff -r ab03cfb3a212 -r 8d086d552909 gen/asmstmt.cpp --- a/gen/asmstmt.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/asmstmt.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -703,7 +703,7 @@ if (asmblock->retn) retty = asmblock->retty; else - retty = llvm::Type::VoidTy; + retty = llvm::Type::getVoidTy(gIR->context()); // build argument types std::vector types; @@ -732,7 +732,7 @@ 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 @@ // 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 @@ std::map::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); diff -r ab03cfb3a212 -r 8d086d552909 gen/classes.cpp --- a/gen/classes.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/classes.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -630,7 +630,7 @@ 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) diff -r ab03cfb3a212 -r 8d086d552909 gen/complex.cpp --- a/gen/complex.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/complex.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -24,16 +24,16 @@ 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); diff -r ab03cfb3a212 -r 8d086d552909 gen/dwarftypes.cpp --- a/gen/dwarftypes.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/dwarftypes.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -21,36 +21,36 @@ using namespace llvm; // Type Definitions std::vectorStructTy_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::vectorStructTy_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::vectorStructTy_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::vectorStructTy_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 @@ mod->addTypeName("llvm.dbg.compile_unit.type", StructTy_llvm_dbg_compile_unit_type); std::vectorStructTy_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::vectorStructTy_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::vectorStructTy_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::vectorStructTy_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::vectorStructTy_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 @@ std::vectorFuncTy_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::vectorFuncTy_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 @@ 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); diff -r ab03cfb3a212 -r 8d086d552909 gen/functions.cpp --- a/gen/functions.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/functions.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -631,15 +631,15 @@ 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 @@ // 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; diff -r ab03cfb3a212 -r 8d086d552909 gen/irstate.h --- a/gen/irstate.h Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/irstate.h Fri Aug 14 00:39:18 2009 +0200 @@ -200,7 +200,7 @@ 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(Callee)) invoke->setAttributes(fn->getAttributes()); diff -r ab03cfb3a212 -r 8d086d552909 gen/llvmhelpers.cpp --- a/gen/llvmhelpers.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/llvmhelpers.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -213,7 +213,7 @@ 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); diff -r ab03cfb3a212 -r 8d086d552909 gen/naked.cpp --- a/gen/naked.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/naked.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -233,11 +233,11 @@ } 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 @@ // 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},"; diff -r ab03cfb3a212 -r 8d086d552909 gen/passes/GarbageCollect2Stack.cpp --- a/gen/passes/GarbageCollect2Stack.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/passes/GarbageCollect2Stack.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -62,13 +62,13 @@ 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 @@ 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 @@ } // 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 @@ // 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 diff -r ab03cfb3a212 -r 8d086d552909 gen/passes/SimplifyDRuntimeCalls.cpp --- a/gen/passes/SimplifyDRuntimeCalls.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/passes/SimplifyDRuntimeCalls.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -82,7 +82,7 @@ /// 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 @@ 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 @@ Constant* C = 0; if ((C = dyn_cast(Cmp->getOperand(0))) || (C = dyn_cast(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 @@ 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(FT->getParamType(1)) || FT->getParamType(2) != VoidPtrTy || diff -r ab03cfb3a212 -r 8d086d552909 gen/runtime.cpp --- a/gen/runtime.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/runtime.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -130,20 +130,20 @@ static const LLType* rt_dg1() { std::vector 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 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 @@ 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 @@ 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"); diff -r ab03cfb3a212 -r 8d086d552909 gen/statements.cpp --- a/gen/statements.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/statements.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -61,7 +61,7 @@ { // 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ // 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 @@ // 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 @@ // 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 @@ // 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 @@ // 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 @@ // 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 @@ // 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 @@ // 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 @@ } // 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 @@ 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 @@ 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 @@ for (size_t i=0; itopfunc(), 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 @@ } 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 @@ // 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 @@ 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 @@ 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 @@ 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 @@ 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); diff -r ab03cfb3a212 -r 8d086d552909 gen/structs.cpp --- a/gen/structs.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/structs.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -162,22 +162,22 @@ { 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; } } diff -r ab03cfb3a212 -r 8d086d552909 gen/tocall.cpp --- a/gen/tocall.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/tocall.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -221,7 +221,7 @@ } ++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 @@ // 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 diff -r ab03cfb3a212 -r 8d086d552909 gen/todebug.cpp --- a/gen/todebug.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/todebug.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -361,13 +361,13 @@ 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); diff -r ab03cfb3a212 -r 8d086d552909 gen/toir.cpp --- a/gen/toir.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/toir.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -408,7 +408,7 @@ 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 @@ 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 @@ 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 @@ 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* 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 @@ { // 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* 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 @@ // 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* 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 @@ // 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 @@ // 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 @@ 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 @@ } 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(); diff -r ab03cfb3a212 -r 8d086d552909 gen/tollvm.cpp --- a/gen/tollvm.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/tollvm.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -180,7 +180,7 @@ const LLType* DtoStructTypeFromArguments(Arguments* arguments) { if (!arguments) - return LLType::VoidTy; + return LLType::getVoidTy(gIR->context()); std::vector types; for (size_t i = 0; i < arguments->dim; i++) @@ -199,8 +199,8 @@ 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 @@ // 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 @@ 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* 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 @@ 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* 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* 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 @@ 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 @@ // void*[] vtbl std::vector 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 @@ if (global.params.os == OSWindows) { // CRITICAL_SECTION.sizeof == 68 - std::vector types(17, LLType::Int32Ty); + std::vector types(17, LLType::getInt32Ty(gIR->context())); return LLStructType::get(gIR->context(), types); } @@ -850,20 +850,20 @@ // pthread_fastlock std::vector 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 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 types; types.push_back(getPtrToType(opaque)); types.push_back(pmutex); @@ -887,7 +887,7 @@ 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 types; diff -r ab03cfb3a212 -r 8d086d552909 gen/toobj.cpp --- a/gen/toobj.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/toobj.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -424,12 +424,12 @@ name.append("6__ctorZ"); std::vector 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 @@ name.append("6__dtorZ"); std::vector 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 @@ name.append("10__unittestZ"); std::vector 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 LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo) { // build ctor type - const LLFunctionType* fty = LLFunctionType::get(LLType::VoidTy, std::vector(), false); + const LLFunctionType* fty = LLFunctionType::get(LLType::getVoidTy(gIR->context()), std::vector(), false); // build ctor name std::string fname = "_D"; @@ -576,7 +576,7 @@ 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 @@ b.push_uint(mi_flags); // function pointer type for next three fields - const LLType* fnptrTy = getPtrToType(LLFunctionType::get(LLType::VoidTy, std::vector(), false)); + const LLType* fnptrTy = getPtrToType(LLFunctionType::get(LLType::getVoidTy(gIR->context()), std::vector(), false)); // ctor llvm::Function* fctor = build_module_ctor(); @@ -807,9 +807,9 @@ 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(), false); + const LLFunctionType* magicfty = LLFunctionType::get(LLType::getVoidTy(gIR->context()), std::vector(), false); std::vector 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); diff -r ab03cfb3a212 -r 8d086d552909 gen/typinf.cpp --- a/gen/typinf.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/gen/typinf.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -319,7 +319,7 @@ // 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 diff -r ab03cfb3a212 -r 8d086d552909 ir/irclass.cpp --- a/ir/irclass.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/ir/irclass.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -83,13 +83,13 @@ // 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 diff -r ab03cfb3a212 -r 8d086d552909 ir/irlandingpad.cpp --- a/ir/irlandingpad.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/ir/irlandingpad.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -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 @@ } // 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 @@ { 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 diff -r ab03cfb3a212 -r 8d086d552909 ir/irstruct.cpp --- a/ir/irstruct.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/ir/irstruct.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -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 @@ { 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; } } diff -r ab03cfb3a212 -r 8d086d552909 ir/irtype.cpp --- a/ir/irtype.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/ir/irtype.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -43,69 +43,70 @@ { 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 @@ ////////////////////////////////////////////////////////////////////////////// IrTypePointer::IrTypePointer(Type * dt) -: IrType(dt, llvm::OpaqueType::get()) +: IrType(dt, llvm::OpaqueType::get(llvm::getGlobalContext())) { } @@ -137,8 +138,8 @@ 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 @@ ////////////////////////////////////////////////////////////////////////////// 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::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 @@ ////////////////////////////////////////////////////////////////////////////// IrTypeArray::IrTypeArray(Type * dt) -: IrType(dt, llvm::OpaqueType::get()) +: IrType(dt, llvm::OpaqueType::get(llvm::getGlobalContext())) { } @@ -199,12 +200,12 @@ // 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); diff -r ab03cfb3a212 -r 8d086d552909 ir/irtypeclass.cpp --- a/ir/irtypeclass.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/ir/irtypeclass.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -23,7 +23,7 @@ : 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 @@ 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; diff -r ab03cfb3a212 -r 8d086d552909 ir/irtypefunction.cpp --- a/ir/irtypefunction.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/ir/irtypefunction.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -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 @@ ////////////////////////////////////////////////////////////////////////////// IrTypeDelegate::IrTypeDelegate(Type * dt) -: IrType(dt, llvm::OpaqueType::get()) +: IrType(dt, llvm::OpaqueType::get(gIR->context())) { } diff -r ab03cfb3a212 -r 8d086d552909 ir/irtypestruct.cpp --- a/ir/irtypestruct.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/ir/irtypestruct.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -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 @@ { 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; } } diff -r ab03cfb3a212 -r 8d086d552909 ir/irvar.cpp --- a/ir/irvar.cpp Thu Aug 06 16:02:14 2009 +0200 +++ b/ir/irvar.cpp Fri Aug 14 00:39:18 2009 +0200 @@ -18,7 +18,7 @@ ////////////////////////////////////////////////////////////////////////////// IrGlobal::IrGlobal(VarDeclaration* v): IrVar(v), - type(llvm::OpaqueType::get()) + type(llvm::OpaqueType::get(llvm::getGlobalContext())) { constInit = NULL; }