diff --git a/gen/aa.cpp b/gen/aa.cpp index 6125b1f3..b979c128 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -105,7 +105,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) llvm::BasicBlock* failbb = llvm::BasicBlock::Create("aaboundscheckfail", gIR->topfunc(), oldend); llvm::BasicBlock* okbb = llvm::BasicBlock::Create("aaboundsok", gIR->topfunc(), oldend); - LLValue* nullaa = gIR->context().getNullValue(ret->getType()); + LLValue* nullaa = LLConstant::getNullValue(ret->getType()); LLValue* cond = gIR->ir->CreateICmpNE(nullaa, ret, "aaboundscheck"); gIR->ir->CreateCondBr(cond, okbb, failbb); diff --git a/gen/arrays.cpp b/gen/arrays.cpp index d326fa73..9c5a3116 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -60,7 +60,7 @@ void DtoSetArrayToNull(LLValue* v) assert(isaPointer(v)); const LLType* t = v->getType()->getContainedType(0); - DtoStore(gIR->context().getNullValue(t), v); + DtoStore(LLConstant::getNullValue(t), v); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/classes.cpp b/gen/classes.cpp index d84d29e0..6066d684 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -211,7 +211,7 @@ void DtoInitClass(TypeClass* tc, LLValue* dst) // monitor always defaults to zero tmp = DtoGEPi(dst,0,1,"monitor"); - val = gIR->context().getNullValue(tmp->getType()->getContainedType(0)); + val = LLConstant::getNullValue(tmp->getType()->getContainedType(0)); DtoStore(val, tmp); // done? @@ -262,7 +262,7 @@ DValue* DtoCastClass(DValue* val, Type* _to) else if (to->ty == Tbool) { IF_LOG Logger::println("to bool"); LLValue* llval = val->getRVal(); - LLValue* zero = gIR->context().getNullValue(llval->getType()); + LLValue* zero = LLConstant::getNullValue(llval->getType()); return new DImValue(_to, gIR->ir->CreateICmpNE(llval, zero, "tmp")); } // class -> integer @@ -326,8 +326,8 @@ DValue* DtoCastClass(DValue* val, Type* _to) // Sure we could have jumped over the code above in this case, but // it's just a GEP and (maybe) a pointer-to-pointer BitCast, so it // should be pretty cheap and perfectly safe even if the original was null. - LLValue* isNull = gIR->ir->CreateICmpEQ(orig, gIR->context().getNullValue(orig->getType()), ".nullcheck"); - v = gIR->ir->CreateSelect(isNull, gIR->context().getNullValue(ifType), v, ".interface"); + LLValue* isNull = gIR->ir->CreateICmpEQ(orig, LLConstant::getNullValue(orig->getType()), ".nullcheck"); + v = gIR->ir->CreateSelect(isNull, LLConstant::getNullValue(ifType), v, ".interface"); // return r-value return new DImValue(_to, v); @@ -602,7 +602,7 @@ static LLConstant* build_offti_array(ClassDeclaration* cd, const LLType* arrayT) LLConstant* ptr; if (nvars == 0) - return gIR->context().getNullValue( arrayT ); + return LLConstant::getNullValue( arrayT ); // array type const llvm::ArrayType* arrTy = llvm::ArrayType::get(arrayInits[0]->getType(), nvars); diff --git a/gen/complex.cpp b/gen/complex.cpp index 57215875..a1daa4e6 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -111,9 +111,9 @@ DValue* DtoComplex(Loc& loc, Type* to, DValue* val) DtoGetComplexParts(loc, to, val, re, im); if(!re) - re = gIR->context().getNullValue(DtoType(baserety)); + re = LLConstant::getNullValue(DtoType(baserety)); if(!im) - im = gIR->context().getNullValue(DtoType(baseimty)); + im = LLConstant::getNullValue(DtoType(baseimty)); LLValue* res = DtoAggrPair(complexTy, re, im); diff --git a/gen/functions.cpp b/gen/functions.cpp index 043945a6..7acb6624 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -811,7 +811,7 @@ void DtoDefineFunction(FuncDeclaration* fd) } } else - llvm::ReturnInst::Create(gIR->context().getNullValue(func->getReturnType()), bb); + llvm::ReturnInst::Create(LLConstant::getNullValue(func->getReturnType()), bb); } // std::cout << *func << std::endl; diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 9e21318b..459616c1 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -463,13 +463,13 @@ DValue* DtoNullValue(Type* type) if (basetype->iscomplex()) { const LLType* basefp = DtoComplexBaseType(basetype); - LLValue* res = DtoAggrPair(DtoType(type), gIR->context().getNullValue(basefp), gIR->context().getNullValue(basefp)); + LLValue* res = DtoAggrPair(DtoType(type), LLConstant::getNullValue(basefp), LLConstant::getNullValue(basefp)); return new DImValue(type, res); } // integer, floating, pointer and class have no special representation else if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || basety == Tclass) { - return new DConstValue(type, gIR->context().getNullValue(lltype)); + return new DConstValue(type, LLConstant::getNullValue(lltype)); } // dynamic array else if (basety == Tarray) @@ -481,7 +481,7 @@ DValue* DtoNullValue(Type* type) // delegate else if (basety == Tdelegate) { - return new DNullValue(type, gIR->context().getNullValue(lltype)); + return new DNullValue(type, LLConstant::getNullValue(lltype)); } // unknown @@ -576,7 +576,7 @@ DValue* DtoCastPtr(Loc& loc, DValue* val, Type* to) } else if (totype->ty == Tbool) { LLValue* src = val->getRVal(); - LLValue* zero = gIR->context().getNullValue(src->getType()); + LLValue* zero = LLConstant::getNullValue(src->getType()); rval = gIR->ir->CreateICmpNE(src, zero, "tmp"); } else if (totype->isintegral()) { @@ -608,7 +608,7 @@ DValue* DtoCastFloat(Loc& loc, DValue* val, Type* to) if (totype->ty == Tbool) { rval = val->getRVal(); - LLValue* zero = gIR->context().getNullValue(rval->getType()); + LLValue* zero = LLConstant::getNullValue(rval->getType()); rval = gIR->ir->CreateFCmpUNE(rval, zero, "tmp"); } else if (totype->iscomplex()) { @@ -1123,7 +1123,7 @@ LLConstant* DtoConstInitializer(Loc loc, Type* type, Initializer* init) { Logger::println("const void initializer"); const LLType* ty = DtoType(type); - _init = gIR->context().getNullValue(ty); + _init = LLConstant::getNullValue(ty); } else { Logger::println("unsupported const initializer: %s", init->toChars()); diff --git a/gen/statements.cpp b/gen/statements.cpp index 355e9d1a..1d1c0378 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -112,7 +112,7 @@ void ReturnStatement::toIR(IRState* p) // and return 0 instead // if we're not in main, just bitcast if (p->topfunc() == p->mainFunc) - v = gIR->context().getNullValue(p->mainFunc->getReturnType()); + v = LLConstant::getNullValue(p->mainFunc->getReturnType()); else v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp"); @@ -1378,7 +1378,7 @@ void WithStatement::toIR(IRState* p) static LLConstant* generate_unique_critical_section() { const LLType* Mty = DtoMutexType(); - return new llvm::GlobalVariable(*gIR->module, Mty, false, llvm::GlobalValue::InternalLinkage, gIR->context().getNullValue(Mty), ".uniqueCS"); + return new llvm::GlobalVariable(*gIR->module, Mty, false, llvm::GlobalValue::InternalLinkage, LLConstant::getNullValue(Mty), ".uniqueCS"); } void SynchronizedStatement::toIR(IRState* p) diff --git a/gen/structs.cpp b/gen/structs.cpp index 569ef19a..2bb46890 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -162,22 +162,22 @@ size_t add_zeros(std::vector& values, size_t diff) { if (is64 && diff % 8 == 0) { - values.push_back(gIR->context().getNullValue(llvm::Type::Int64Ty)); + values.push_back(LLConstant::getNullValue(llvm::Type::Int64Ty)); diff -= 8; } else if (diff % 4 == 0) { - values.push_back(gIR->context().getNullValue(llvm::Type::Int32Ty)); + values.push_back(LLConstant::getNullValue(llvm::Type::Int32Ty)); diff -= 4; } else if (diff % 2 == 0) { - values.push_back(gIR->context().getNullValue(llvm::Type::Int16Ty)); + values.push_back(LLConstant::getNullValue(llvm::Type::Int16Ty)); diff -= 2; } else { - values.push_back(gIR->context().getNullValue(llvm::Type::Int8Ty)); + values.push_back(LLConstant::getNullValue(llvm::Type::Int8Ty)); diff -= 1; } } diff --git a/gen/todebug.cpp b/gen/todebug.cpp index d5d35ac5..325e46d4 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -19,7 +19,7 @@ using namespace llvm::dwarf; -#define DBG_NULL ( gIR->context().getNullValue(DBG_TYPE) ) +#define DBG_NULL ( LLConstant::getNullValue(DBG_TYPE) ) #define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) ) #define DBG_CAST(X) ( llvm::ConstantExpr::getBitCast(X, DBG_TYPE) ) @@ -297,7 +297,7 @@ static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit std::vector initvals(11); initvals[0] = DBG_TAG(DW_TAG_structure_type); for (int i = 1; i < initvals.size(); ++i) - initvals[i] = gIR->context().getNullValue(getDwarfCompositeTypeType()->getContainedType(i)); + initvals[i] = LLConstant::getNullValue(getDwarfCompositeTypeType()->getContainedType(i)); gv->setInitializer(LLConstantStruct::get(getDwarfCompositeTypeType(), initvals)); ir->diCompositeType = llvm::DICompositeType(gv); diff --git a/gen/toir.cpp b/gen/toir.cpp index 7fae163b..4ca39d2e 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -341,7 +341,7 @@ LLConstant* NullExp::toConstElem(IRState* p) return llvm::ConstantAggregateZero::get(t); } else { - return gIR->context().getNullValue(t); + return LLConstant::getNullValue(t); } assert(0); return NULL; @@ -1656,7 +1656,7 @@ DValue* DeleteExp::toElem(IRState* p) LLValue* rval = dval->getRVal(); DtoDeleteMemory(rval); if (dval->isVar()) - DtoStore(gIR->context().getNullValue(rval->getType()), dval->getLVal()); + DtoStore(LLConstant::getNullValue(rval->getType()), dval->getLVal()); } // class else if (et->ty == Tclass) @@ -1680,7 +1680,7 @@ DValue* DeleteExp::toElem(IRState* p) } if (dval->isVar()) { LLValue* lval = dval->getLVal(); - DtoStore(gIR->context().getNullValue(lval->getType()->getContainedType(0)), lval); + DtoStore(LLConstant::getNullValue(lval->getType()->getContainedType(0)), lval); } } // dyn array @@ -2547,7 +2547,7 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p) // it should be possible to avoid the temporary in some cases LLValue* tmp = DtoAlloca(type,"aaliteral"); DValue* aa = new DVarValue(type, tmp); - DtoStore(gIR->context().getNullValue(DtoType(type)), tmp); + DtoStore(LLConstant::getNullValue(DtoType(type)), tmp); const size_t n = keys->dim; for (size_t i=0; icontext().getNullValue(lhs->getType()); + rhs = LLConstant::getNullValue(lhs->getType()); } LLValue* l = gIR->ir->CreateExtractValue(lhs, 0); @@ -740,7 +740,7 @@ llvm::ConstantPointerNull* getNullPtr(const LLType* t) LLConstant* getNullValue(const LLType* t) { - return gIR->context().getNullValue(t); + return LLConstant::getNullValue(t); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/toobj.cpp b/gen/toobj.cpp index c2238200..0c7dabcc 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -557,7 +557,7 @@ static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo) // provide the default initializer const LLStructType* modulerefTy = DtoModuleReferenceType(); std::vector mrefvalues; - mrefvalues.push_back(gIR->context().getNullValue(modulerefTy->getContainedType(0))); + mrefvalues.push_back(LLConstant::getNullValue(modulerefTy->getContainedType(0))); mrefvalues.push_back(llvm::ConstantExpr::getBitCast(moduleinfo, modulerefTy->getContainedType(1))); LLConstant* thismrefinit = LLConstantStruct::get(modulerefTy, mrefvalues); diff --git a/ir/irstruct.cpp b/ir/irstruct.cpp index 8b68295d..cceea3f2 100644 --- a/ir/irstruct.cpp +++ b/ir/irstruct.cpp @@ -117,22 +117,22 @@ size_t add_zeros(std::vector& constants, size_t diff) { if (global.params.is64bit && diff % 8 == 0) { - constants.push_back(gIR->context().getNullValue(llvm::Type::Int64Ty)); + constants.push_back(LLConstant::getNullValue(llvm::Type::Int64Ty)); diff -= 8; } else if (diff % 4 == 0) { - constants.push_back(gIR->context().getNullValue(llvm::Type::Int32Ty)); + constants.push_back(LLConstant::getNullValue(llvm::Type::Int32Ty)); diff -= 4; } else if (diff % 2 == 0) { - constants.push_back(gIR->context().getNullValue(llvm::Type::Int16Ty)); + constants.push_back(LLConstant::getNullValue(llvm::Type::Int16Ty)); diff -= 2; } else { - constants.push_back(gIR->context().getNullValue(llvm::Type::Int8Ty)); + constants.push_back(LLConstant::getNullValue(llvm::Type::Int8Ty)); diff -= 1; } }