mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-28 17:43:14 +01:00
More factory methods moved to LLVMContext
This commit is contained in:
@@ -60,7 +60,7 @@ struct X86_cfloat_rewrite : ABIRewrite
|
||||
rpart = gIR->ir->CreateBitCast(rpart, LLType::FloatTy, ".re");
|
||||
|
||||
// extract imag part
|
||||
LLValue* ipart = gIR->ir->CreateLShr(in, LLConstantInt::get(LLType::Int64Ty, 32, false));
|
||||
LLValue* ipart = gIR->ir->CreateLShr(in, gIR->context().getConstantInt(LLType::Int64Ty, 32, false));
|
||||
ipart = gIR->ir->CreateTrunc(ipart, LLType::Int32Ty);
|
||||
ipart = gIR->ir->CreateBitCast(ipart, LLType::FloatTy, ".im");
|
||||
|
||||
@@ -87,7 +87,7 @@ struct X86_cfloat_rewrite : ABIRewrite
|
||||
// zext to i64
|
||||
i = gIR->ir->CreateZExt(i, LLType::Int64Ty);
|
||||
// shift up
|
||||
i = gIR->ir->CreateShl(i, LLConstantInt::get(LLType::Int64Ty, 32, false));
|
||||
i = gIR->ir->CreateShl(i, gIR->context().getConstantInt(LLType::Int64Ty, 32, false));
|
||||
|
||||
// combine and return
|
||||
return v = gIR->ir->CreateOr(r, i);
|
||||
|
||||
@@ -309,7 +309,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit)
|
||||
|
||||
LLConstant* constarr;
|
||||
if (mismatch)
|
||||
constarr = LLConstantStruct::get(initvals);
|
||||
constarr = gIR->context().getConstantStruct(initvals);
|
||||
else
|
||||
constarr = LLConstantArray::get(LLArrayType::get(llelemty, arrlen), initvals);
|
||||
|
||||
@@ -394,7 +394,7 @@ void DtoStaticArrayCopy(LLValue* dst, LLValue* src)
|
||||
LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr)
|
||||
{
|
||||
LLConstant* values[2] = { dim, ptr };
|
||||
return llvm::ConstantStruct::get(values, 2);
|
||||
return gIR->context().getConstantStruct(values, 2);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -826,8 +826,8 @@ LLValue* DtoArrayCastLength(LLValue* len, const LLType* elemty, const LLType* ne
|
||||
|
||||
LLSmallVector<LLValue*, 3> args;
|
||||
args.push_back(len);
|
||||
args.push_back(llvm::ConstantInt::get(DtoSize_t(), esz, false));
|
||||
args.push_back(llvm::ConstantInt::get(DtoSize_t(), nsz, false));
|
||||
args.push_back(gIR->context().getConstantInt(DtoSize_t(), esz, false));
|
||||
args.push_back(gIR->context().getConstantInt(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 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to)
|
||||
fatal();
|
||||
}
|
||||
|
||||
rval2 = llvm::ConstantInt::get(DtoSize_t(), arrty->getNumElements(), false);
|
||||
rval2 = gIR->context().getConstantInt(DtoSize_t(), arrty->getNumElements(), false);
|
||||
if (fromtype->nextOf()->size() != totype->nextOf()->size())
|
||||
rval2 = DtoArrayCastLength(rval2, ety, ptrty->getContainedType(0));
|
||||
rval = DtoBitCast(uval, ptrty);
|
||||
|
||||
@@ -769,7 +769,7 @@ void AsmBlockStatement::toIR(IRState* p)
|
||||
for(it = gotoToVal.begin(); it != end; ++it)
|
||||
{
|
||||
llvm::BasicBlock* casebb = llvm::BasicBlock::Create("case", p->topfunc(), bb);
|
||||
sw->addCase(llvm::ConstantInt::get(llvm::IntegerType::get(32), it->second), casebb);
|
||||
sw->addCase(gIR->context().getConstantInt(llvm::IntegerType::get(32), it->second), casebb);
|
||||
|
||||
p->scope() = IRScope(casebb,bb);
|
||||
DtoGoto(loc, it->first, enclosingFinally);
|
||||
|
||||
@@ -515,7 +515,7 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to)
|
||||
}
|
||||
|
||||
if (to->ty == Tbool) {
|
||||
LLValue* zero = LLConstantInt::get(rval->getType(), 0, false);
|
||||
LLValue* zero = gIR->context().getConstantInt(rval->getType(), 0, false);
|
||||
rval = gIR->ir->CreateICmpNE(rval, zero, "tmp");
|
||||
}
|
||||
else if (to->isintegral()) {
|
||||
|
||||
@@ -57,24 +57,24 @@ namespace {
|
||||
// Helper functions
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void EmitMemSet(IRBuilder<>& B, Value* Dst, Value* Val, Value* Len,
|
||||
const Analysis& A) {
|
||||
void EmitMemSet(LLVMContext& Context, 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 = ConstantInt::get(Type::Int32Ty, 1);
|
||||
Value *Align = Context.getConstantInt(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(IRBuilder<>& B, Value* Dst, Value* Len,
|
||||
const Analysis& A) {
|
||||
EmitMemSet(B, Dst, ConstantInt::get(Type::Int8Ty, 0), Len, A);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -178,11 +178,11 @@ namespace {
|
||||
if (Initialized) {
|
||||
// For now, only zero-init is supported.
|
||||
uint64_t size = A.TD.getTypeStoreSize(Ty);
|
||||
Value* TypeSize = ConstantInt::get(arrSize->getType(), size);
|
||||
Value* TypeSize = Context->getConstantInt(arrSize->getType(), size);
|
||||
// Use the original B to put initialization at the
|
||||
// allocation site.
|
||||
Value* Size = B.CreateMul(TypeSize, arrSize);
|
||||
EmitMemZero(B, alloca, Size, A);
|
||||
EmitMemZero(*Context, B, alloca, Size, A);
|
||||
}
|
||||
|
||||
return alloca;
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace {
|
||||
bool* Changed;
|
||||
const TargetData *TD;
|
||||
AliasAnalysis *AA;
|
||||
LLVMContext *Context;
|
||||
|
||||
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
|
||||
Value *CastToCStr(Value *V, IRBuilder<> &B);
|
||||
@@ -71,6 +72,8 @@ namespace {
|
||||
this->Changed = &Changed;
|
||||
this->TD = &TD;
|
||||
this->AA = &AA;
|
||||
if (CI->getCalledFunction())
|
||||
Context = CI->getCalledFunction()->getContext();
|
||||
return CallOptimizer(CI->getCalledFunction(), CI, B);
|
||||
}
|
||||
};
|
||||
@@ -91,7 +94,7 @@ Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len,
|
||||
Tys[0] = Len->getType();
|
||||
Value *MemCpy = Intrinsic::getDeclaration(M, IID, Tys, 1);
|
||||
return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src, B), Len,
|
||||
ConstantInt::get(Type::Int32Ty, Align));
|
||||
Context->getConstantInt(Type::Int32Ty, Align));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -177,7 +180,7 @@ struct VISIBILITY_HIDDEN ArrayCastLenOpt : public LibCallOptimization {
|
||||
APInt Quot, Rem;
|
||||
APInt::udivrem(OldInt->getValue(), NewInt->getValue(), Quot, Rem);
|
||||
if (Rem == 0)
|
||||
return B.CreateMul(OldLen, ConstantInt::get(Quot));
|
||||
return B.CreateMul(OldLen, Context->getConstantInt(Quot));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -198,7 +201,7 @@ struct VISIBILITY_HIDDEN AllocationOpt : public LibCallOptimization {
|
||||
Constant* C = 0;
|
||||
if ((C = dyn_cast<Constant>(Cmp->getOperand(0)))
|
||||
|| (C = dyn_cast<Constant>(Cmp->getOperand(1)))) {
|
||||
Value* Result = ConstantInt::get(Type::Int1Ty, !Cmp->isTrueWhenEqual());
|
||||
Value* Result = Context->getConstantInt(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
|
||||
|
||||
@@ -142,7 +142,7 @@ void RTTIBuilder::push_funcptr(FuncDeclaration* fd, Type* castto)
|
||||
void RTTIBuilder::finalize(IrGlobal* tid)
|
||||
{
|
||||
// create the inititalizer
|
||||
LLConstant* tiInit = llvm::ConstantStruct::get(&inits[0], inits.size(), false);
|
||||
LLConstant* tiInit = gIR->context().getConstantStruct(&inits[0], inits.size(), false);
|
||||
|
||||
// refine global type
|
||||
llvm::cast<llvm::OpaqueType>(tid->type.get())->refineAbstractTypeTo(tiInit->getType());
|
||||
@@ -154,5 +154,5 @@ void RTTIBuilder::finalize(IrGlobal* tid)
|
||||
LLConstant* RTTIBuilder::get_constant()
|
||||
{
|
||||
// just return the inititalizer
|
||||
return llvm::ConstantStruct::get(&inits[0], inits.size(), false);
|
||||
return gIR->context().getConstantStruct(&inits[0], inits.size(), false);
|
||||
}
|
||||
|
||||
@@ -1032,7 +1032,7 @@ void ForeachStatement::toIR(IRState* p)
|
||||
keyvar = DtoRawVarDeclaration(key);
|
||||
else
|
||||
keyvar = DtoRawAlloca(keytype, 0, "foreachkey"); // FIXME: align?
|
||||
LLValue* zerokey = llvm::ConstantInt::get(keytype,0,false);
|
||||
LLValue* zerokey = gIR->context().getConstantInt(keytype,0,false);
|
||||
|
||||
// value
|
||||
Logger::println("value = %s", value->toPrettyChars());
|
||||
@@ -1089,7 +1089,7 @@ void ForeachStatement::toIR(IRState* p)
|
||||
}
|
||||
else if (op == TOKforeach_reverse) {
|
||||
done = p->ir->CreateICmpUGT(load, zerokey, "tmp");
|
||||
load = p->ir->CreateSub(load, llvm::ConstantInt::get(keytype, 1, false), "tmp");
|
||||
load = p->ir->CreateSub(load, gIR->context().getConstantInt(keytype, 1, false), "tmp");
|
||||
DtoStore(load, keyvar);
|
||||
}
|
||||
llvm::BranchInst::Create(bodybb, endbb, done, p->scopebb());
|
||||
@@ -1098,7 +1098,7 @@ void ForeachStatement::toIR(IRState* p)
|
||||
p->scope() = IRScope(bodybb,nextbb);
|
||||
|
||||
// get value for this iteration
|
||||
LLConstant* zero = llvm::ConstantInt::get(keytype,0,false);
|
||||
LLConstant* zero = gIR->context().getConstantInt(keytype,0,false);
|
||||
LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp");
|
||||
LLValue* gep = DtoGEP1(val,loadedKey);
|
||||
|
||||
@@ -1126,7 +1126,7 @@ void ForeachStatement::toIR(IRState* p)
|
||||
p->scope() = IRScope(nextbb,endbb);
|
||||
if (op == TOKforeach) {
|
||||
LLValue* load = DtoLoad(keyvar);
|
||||
load = p->ir->CreateAdd(load, llvm::ConstantInt::get(keytype, 1, false), "tmp");
|
||||
load = p->ir->CreateAdd(load, gIR->context().getConstantInt(keytype, 1, false), "tmp");
|
||||
DtoStore(load, keyvar);
|
||||
}
|
||||
llvm::BranchInst::Create(condbb, p->scopebb());
|
||||
|
||||
@@ -108,7 +108,7 @@ LLValue* DtoStructEquals(TOK op, DValue* lhs, DValue* rhs)
|
||||
// call memcmp
|
||||
size_t sz = getTypePaddedSize(DtoType(t));
|
||||
LLValue* val = DtoMemCmp(lhs->getRVal(), rhs->getRVal(), DtoConstSize_t(sz));
|
||||
return gIR->ir->CreateICmp(cmpop, val, LLConstantInt::get(val->getType(), 0, false), "tmp");
|
||||
return gIR->ir->CreateICmp(cmpop, val, gIR->context().getConstantInt(val->getType(), 0, false), "tmp");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -207,7 +207,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::Attribut
|
||||
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 = llvm::ConstantStruct::get(pinits);
|
||||
tiinits = gIR->context().getConstantStruct(pinits);
|
||||
LLValue* typeinfoarrayparam = new llvm::GlobalVariable(*gIR->module, tiarrty,
|
||||
true, llvm::GlobalValue::InternalLinkage, tiinits, "._arguments.array");
|
||||
|
||||
|
||||
@@ -361,13 +361,13 @@ static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit
|
||||
vals[4] = DtoConstInt(linnum);
|
||||
|
||||
// size in bits
|
||||
vals[5] = LLConstantInt::get(LLType::Int64Ty, getTypeBitSize(T), false);
|
||||
vals[5] = gIR->context().getConstantInt(LLType::Int64Ty, getTypeBitSize(T), false);
|
||||
|
||||
// alignment in bits
|
||||
vals[6] = LLConstantInt::get(LLType::Int64Ty, getABITypeAlign(T)*8, false);
|
||||
vals[6] = gIR->context().getConstantInt(LLType::Int64Ty, getABITypeAlign(T)*8, false);
|
||||
|
||||
// offset in bits
|
||||
vals[7] = LLConstantInt::get(LLType::Int64Ty, 0, false);
|
||||
vals[7] = gIR->context().getConstantInt(LLType::Int64Ty, 0, false);
|
||||
|
||||
// FIXME: dont know what this is
|
||||
vals[8] = DtoConstUint(0);
|
||||
|
||||
42
gen/toir.cpp
42
gen/toir.cpp
@@ -288,11 +288,11 @@ LLConstant* IntegerExp::toConstElem(IRState* p)
|
||||
const LLType* t = DtoType(type);
|
||||
if (isaPointer(t)) {
|
||||
Logger::println("pointer");
|
||||
LLConstant* i = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)value,false);
|
||||
LLConstant* i = gIR->context().getConstantInt(DtoSize_t(),(uint64_t)value,false);
|
||||
return llvm::ConstantExpr::getIntToPtr(i, t);
|
||||
}
|
||||
assert(llvm::isa<LLIntegerType>(t));
|
||||
LLConstant* c = llvm::ConstantInt::get(t,(uint64_t)value,!type->isunsigned());
|
||||
LLConstant* c = gIR->context().getConstantInt(t,(uint64_t)value,!type->isunsigned());
|
||||
assert(c);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "value = " << *c << '\n';
|
||||
@@ -402,16 +402,16 @@ DValue* StringExp::toElem(IRState* p)
|
||||
if (cty->size() == 1) {
|
||||
uint8_t* str = (uint8_t*)string;
|
||||
std::string cont((char*)str, len);
|
||||
_init = llvm::ConstantArray::get(cont,true);
|
||||
_init = gIR->context().getConstantArray(cont,true);
|
||||
}
|
||||
else if (cty->size() == 2) {
|
||||
uint16_t* str = (uint16_t*)string;
|
||||
std::vector<LLConstant*> vals;
|
||||
vals.reserve(len+1);
|
||||
for(size_t i=0; i<len; ++i) {
|
||||
vals.push_back(llvm::ConstantInt::get(ct, str[i], false));;
|
||||
vals.push_back(gIR->context().getConstantInt(ct, str[i], false));;
|
||||
}
|
||||
vals.push_back(llvm::ConstantInt::get(ct, 0, false));
|
||||
vals.push_back(gIR->context().getConstantInt(ct, 0, false));
|
||||
_init = llvm::ConstantArray::get(at,vals);
|
||||
}
|
||||
else if (cty->size() == 4) {
|
||||
@@ -419,9 +419,9 @@ DValue* StringExp::toElem(IRState* p)
|
||||
std::vector<LLConstant*> vals;
|
||||
vals.reserve(len+1);
|
||||
for(size_t i=0; i<len; ++i) {
|
||||
vals.push_back(llvm::ConstantInt::get(ct, str[i], false));;
|
||||
vals.push_back(gIR->context().getConstantInt(ct, str[i], false));;
|
||||
}
|
||||
vals.push_back(llvm::ConstantInt::get(ct, 0, false));
|
||||
vals.push_back(gIR->context().getConstantInt(ct, 0, false));
|
||||
_init = llvm::ConstantArray::get(at,vals);
|
||||
}
|
||||
else
|
||||
@@ -432,12 +432,12 @@ DValue* StringExp::toElem(IRState* p)
|
||||
Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n';
|
||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(*gIR->module,at,true,_linkage,_init,".str");
|
||||
|
||||
llvm::ConstantInt* zero = llvm::ConstantInt::get(LLType::Int32Ty, 0, false);
|
||||
llvm::ConstantInt* zero = gIR->context().getConstantInt(LLType::Int32Ty, 0, false);
|
||||
LLConstant* idxs[2] = { zero, zero };
|
||||
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
||||
|
||||
if (dtype->ty == Tarray) {
|
||||
LLConstant* clen = llvm::ConstantInt::get(DtoSize_t(),len,false);
|
||||
LLConstant* clen = gIR->context().getConstantInt(DtoSize_t(),len,false);
|
||||
return new DImValue(type, DtoConstSlice(clen, arrptr));
|
||||
}
|
||||
else if (dtype->ty == Tsarray) {
|
||||
@@ -473,17 +473,17 @@ LLConstant* StringExp::toConstElem(IRState* p)
|
||||
if (cty->size() == 1) {
|
||||
uint8_t* str = (uint8_t*)string;
|
||||
std::string cont((char*)str, len);
|
||||
_init = llvm::ConstantArray::get(cont, nullterm);
|
||||
_init = gIR->context().getConstantArray(cont, nullterm);
|
||||
}
|
||||
else if (cty->size() == 2) {
|
||||
uint16_t* str = (uint16_t*)string;
|
||||
std::vector<LLConstant*> vals;
|
||||
vals.reserve(len+1);
|
||||
for(size_t i=0; i<len; ++i) {
|
||||
vals.push_back(llvm::ConstantInt::get(ct, str[i], false));;
|
||||
vals.push_back(gIR->context().getConstantInt(ct, str[i], false));;
|
||||
}
|
||||
if (nullterm)
|
||||
vals.push_back(llvm::ConstantInt::get(ct, 0, false));
|
||||
vals.push_back(gIR->context().getConstantInt(ct, 0, false));
|
||||
_init = llvm::ConstantArray::get(at,vals);
|
||||
}
|
||||
else if (cty->size() == 4) {
|
||||
@@ -491,10 +491,10 @@ LLConstant* StringExp::toConstElem(IRState* p)
|
||||
std::vector<LLConstant*> vals;
|
||||
vals.reserve(len+1);
|
||||
for(size_t i=0; i<len; ++i) {
|
||||
vals.push_back(llvm::ConstantInt::get(ct, str[i], false));;
|
||||
vals.push_back(gIR->context().getConstantInt(ct, str[i], false));;
|
||||
}
|
||||
if (nullterm)
|
||||
vals.push_back(llvm::ConstantInt::get(ct, 0, false));
|
||||
vals.push_back(gIR->context().getConstantInt(ct, 0, false));
|
||||
_init = llvm::ConstantArray::get(at,vals);
|
||||
}
|
||||
else
|
||||
@@ -508,7 +508,7 @@ LLConstant* StringExp::toConstElem(IRState* p)
|
||||
llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;
|
||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(*gIR->module,_init->getType(),true,_linkage,_init,".str");
|
||||
|
||||
llvm::ConstantInt* zero = llvm::ConstantInt::get(LLType::Int32Ty, 0, false);
|
||||
llvm::ConstantInt* zero = gIR->context().getConstantInt(LLType::Int32Ty, 0, false);
|
||||
LLConstant* idxs[2] = { zero, zero };
|
||||
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
||||
|
||||
@@ -516,7 +516,7 @@ LLConstant* StringExp::toConstElem(IRState* p)
|
||||
return arrptr;
|
||||
}
|
||||
else if (t->ty == Tarray) {
|
||||
LLConstant* clen = llvm::ConstantInt::get(DtoSize_t(),len,false);
|
||||
LLConstant* clen = gIR->context().getConstantInt(DtoSize_t(),len,false);
|
||||
return DtoConstSlice(clen, arrptr);
|
||||
}
|
||||
|
||||
@@ -1525,7 +1525,7 @@ DValue* PostExp::toElem(IRState* p)
|
||||
if (e1type->isintegral())
|
||||
{
|
||||
assert(e2type->isintegral());
|
||||
LLValue* one = llvm::ConstantInt::get(val->getType(), 1, !e2type->isunsigned());
|
||||
LLValue* one = gIR->context().getConstantInt(val->getType(), 1, !e2type->isunsigned());
|
||||
if (op == TOKplusplus) {
|
||||
post = llvm::BinaryOperator::CreateAdd(val,one,"tmp",p->scopebb());
|
||||
}
|
||||
@@ -1536,8 +1536,8 @@ DValue* PostExp::toElem(IRState* p)
|
||||
else if (e1type->ty == Tpointer)
|
||||
{
|
||||
assert(e2type->isintegral());
|
||||
LLConstant* minusone = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)-1,true);
|
||||
LLConstant* plusone = llvm::ConstantInt::get(DtoSize_t(),(uint64_t)1,false);
|
||||
LLConstant* minusone = gIR->context().getConstantInt(DtoSize_t(),(uint64_t)-1,true);
|
||||
LLConstant* plusone = gIR->context().getConstantInt(DtoSize_t(),(uint64_t)1,false);
|
||||
LLConstant* whichone = (op == TOKplusplus) ? plusone : minusone;
|
||||
post = llvm::GetElementPtrInst::Create(val, whichone, "tmp", p->scopebb());
|
||||
}
|
||||
@@ -2146,7 +2146,7 @@ DValue* ComExp::toElem(IRState* p)
|
||||
DValue* u = e1->toElem(p);
|
||||
|
||||
LLValue* value = u->getRVal();
|
||||
LLValue* minusone = llvm::ConstantInt::get(value->getType(), (uint64_t)-1, true);
|
||||
LLValue* minusone = gIR->context().getConstantInt(value->getType(), (uint64_t)-1, true);
|
||||
value = llvm::BinaryOperator::Create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb());
|
||||
|
||||
return new DImValue(type, value);
|
||||
@@ -2501,7 +2501,7 @@ LLConstant* StructLiteralExp::toConstElem(IRState* p)
|
||||
constvals[i] = llvm::cast<LLConstant>(values[i]);
|
||||
|
||||
// return constant struct
|
||||
return LLConstantStruct::get(constvals, sd->ir.irStruct->packed);
|
||||
return gIR->context().getConstantStruct(constvals, sd->ir.irStruct->packed);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -532,23 +532,23 @@ void DtoMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device)
|
||||
|
||||
llvm::ConstantInt* DtoConstSize_t(uint64_t i)
|
||||
{
|
||||
return llvm::ConstantInt::get(DtoSize_t(), i, false);
|
||||
return gIR->context().getConstantInt(DtoSize_t(), i, false);
|
||||
}
|
||||
llvm::ConstantInt* DtoConstUint(unsigned i)
|
||||
{
|
||||
return llvm::ConstantInt::get(LLType::Int32Ty, i, false);
|
||||
return gIR->context().getConstantInt(LLType::Int32Ty, i, false);
|
||||
}
|
||||
llvm::ConstantInt* DtoConstInt(int i)
|
||||
{
|
||||
return llvm::ConstantInt::get(LLType::Int32Ty, i, true);
|
||||
return gIR->context().getConstantInt(LLType::Int32Ty, i, true);
|
||||
}
|
||||
LLConstant* DtoConstBool(bool b)
|
||||
{
|
||||
return llvm::ConstantInt::get(LLType::Int1Ty, b, false);
|
||||
return gIR->context().getConstantInt(LLType::Int1Ty, b, false);
|
||||
}
|
||||
llvm::ConstantInt* DtoConstUbyte(unsigned char i)
|
||||
{
|
||||
return llvm::ConstantInt::get(LLType::Int8Ty, i, false);
|
||||
return gIR->context().getConstantInt(LLType::Int8Ty, i, false);
|
||||
}
|
||||
|
||||
LLConstant* DtoConstFP(Type* t, long double value)
|
||||
@@ -562,7 +562,7 @@ LLConstant* DtoConstFP(Type* t, long double value)
|
||||
uint64_t bits[] = {0, 0};
|
||||
bits[0] = *(uint64_t*)&value;
|
||||
bits[1] = *(uint16_t*)((uint64_t*)&value + 1);
|
||||
return LLConstantFP::get(APFloat(APInt(80, 2, bits)));
|
||||
return gIR->context().getConstantFP(APFloat(APInt(80, 2, bits)));
|
||||
} else {
|
||||
assert(0 && "Unknown floating point type encountered");
|
||||
}
|
||||
@@ -573,7 +573,7 @@ LLConstant* DtoConstFP(Type* t, long double value)
|
||||
LLConstant* DtoConstString(const char* str)
|
||||
{
|
||||
std::string s(str?str:"");
|
||||
LLConstant* init = llvm::ConstantArray::get(s, true);
|
||||
LLConstant* init = gIR->context().getConstantArray(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) };
|
||||
@@ -585,7 +585,7 @@ LLConstant* DtoConstString(const char* str)
|
||||
LLConstant* DtoConstStringPtr(const char* str, const char* section)
|
||||
{
|
||||
std::string s(str);
|
||||
LLConstant* init = llvm::ConstantArray::get(s, true);
|
||||
LLConstant* init = gIR->context().getConstantArray(s, true);
|
||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
|
||||
*gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str");
|
||||
if (section) gvar->setSection(section);
|
||||
|
||||
@@ -315,7 +315,7 @@ void DtoResolveTypeInfo(TypeInfoDeclaration* tid)
|
||||
mdVals[TD_Confirm] = llvm::cast<MDNodeField>(irg->value);
|
||||
mdVals[TD_Type] = llvm::UndefValue::get(DtoType(tid->tinfo));
|
||||
// Construct the metadata
|
||||
llvm::MDNode* metadata = llvm::MDNode::get(mdVals, TD_NumFields);
|
||||
llvm::MDNode* metadata = gIR->context().getMDNode(mdVals, TD_NumFields);
|
||||
// Insert it into the module
|
||||
new llvm::GlobalVariable(*gIR->module, metadata->getType(), true,
|
||||
METADATA_LINKAGE_TYPE, metadata, metaname);
|
||||
@@ -434,9 +434,9 @@ void TypeInfoEnumDeclaration::llvmDefine()
|
||||
{
|
||||
const LLType* memty = DtoType(sd->memtype);
|
||||
#if DMDV2
|
||||
LLConstant* C = llvm::ConstantInt::get(memty, sd->defaultval->toInteger(), !sd->memtype->isunsigned());
|
||||
LLConstant* C = gIR->context().getConstantInt(memty, sd->defaultval->toInteger(), !sd->memtype->isunsigned());
|
||||
#else
|
||||
LLConstant* C = llvm::ConstantInt::get(memty, sd->defaultval, !sd->memtype->isunsigned());
|
||||
LLConstant* C = gIR->context().getConstantInt(memty, sd->defaultval, !sd->memtype->isunsigned());
|
||||
#endif
|
||||
b.push_void_array(C, sd->memtype, sd);
|
||||
}
|
||||
|
||||
@@ -82,10 +82,10 @@ LLGlobalVariable * IrStruct::getClassInfoSymbol()
|
||||
// Construct the fields
|
||||
MDNodeField* mdVals[CD_NumFields];
|
||||
mdVals[CD_BodyType] = llvm::UndefValue::get(bodyType);
|
||||
mdVals[CD_Finalize] = LLConstantInt::get(LLType::Int1Ty, hasDestructor);
|
||||
mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::Int1Ty, hasCustomDelete);
|
||||
mdVals[CD_Finalize] = gIR->context().getConstantInt(LLType::Int1Ty, hasDestructor);
|
||||
mdVals[CD_CustomDelete] = gIR->context().getConstantInt(LLType::Int1Ty, hasCustomDelete);
|
||||
// Construct the metadata
|
||||
llvm::MDNode* metadata = llvm::MDNode::get(mdVals, CD_NumFields);
|
||||
llvm::MDNode* metadata = gIR->context().getMDNode(mdVals, CD_NumFields);
|
||||
// Insert it into the module
|
||||
new llvm::GlobalVariable(*gIR->module, metadata->getType(), true,
|
||||
METADATA_LINKAGE_TYPE, metadata, CD_PREFIX + initname);
|
||||
@@ -170,7 +170,7 @@ LLConstant * IrStruct::getVtblInit()
|
||||
}
|
||||
|
||||
// build the constant struct
|
||||
constVtbl = llvm::ConstantStruct::get(constants, false);
|
||||
constVtbl = gIR->context().getConstantStruct(constants, false);
|
||||
|
||||
#if 0
|
||||
IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl;
|
||||
@@ -314,7 +314,7 @@ LLConstant * IrStruct::createClassDefaultInitializer()
|
||||
addBaseClassInits(constants, cd, offset, field_index);
|
||||
|
||||
// build the constant
|
||||
llvm::Constant* definit = llvm::ConstantStruct::get(constants, false);
|
||||
llvm::Constant* definit = gIR->context().getConstantStruct(constants, false);
|
||||
|
||||
return definit;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instan
|
||||
}
|
||||
|
||||
// build the vtbl constant
|
||||
llvm::Constant* vtbl_constant = llvm::ConstantStruct::get(constants, false);
|
||||
llvm::Constant* vtbl_constant = gIR->context().getConstantStruct(constants, false);
|
||||
|
||||
// create the global variable to hold it
|
||||
llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl);
|
||||
@@ -481,7 +481,7 @@ LLConstant * IrStruct::getClassInfoInterfaces()
|
||||
|
||||
// create Interface struct
|
||||
LLConstant* inits[3] = { ci, vtb, off };
|
||||
LLConstant* entry = llvm::ConstantStruct::get(inits, 3);
|
||||
LLConstant* entry = gIR->context().getConstantStruct(inits, 3);
|
||||
constants.push_back(entry);
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ LLConstant * IrStruct::getClassInfoInterfaces()
|
||||
constants[0]->getType(),
|
||||
n);
|
||||
|
||||
LLConstant* arr = llvm::ConstantArray::get(
|
||||
LLConstant* arr = gIR->context().getConstantArray(
|
||||
array_type,
|
||||
&constants[0],
|
||||
n);
|
||||
|
||||
@@ -133,7 +133,7 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB)
|
||||
}
|
||||
// if there's a finally, the eh table has to have a 0 action
|
||||
if(hasFinally)
|
||||
selectorargs.push_back(llvm::ConstantInt::get(LLType::Int32Ty, 0));
|
||||
selectorargs.push_back(gIR->context().getConstantInt(LLType::Int32Ty, 0));
|
||||
|
||||
// personality fn
|
||||
llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_personality");
|
||||
@@ -186,7 +186,7 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB)
|
||||
}
|
||||
// dubious comment
|
||||
// catches matched first get the largest switchval, so do size - unique int
|
||||
llvm::ConstantInt* switchval = llvm::ConstantInt::get(DtoSize_t(), catchToInt[rit->catchType]);
|
||||
llvm::ConstantInt* switchval = gIR->context().getConstantInt(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);
|
||||
|
||||
@@ -195,7 +195,7 @@ LLConstant * IrStruct::createStructDefaultInitializer()
|
||||
}
|
||||
|
||||
// build constant struct
|
||||
llvm::Constant* definit = llvm::ConstantStruct::get(constants, packed);
|
||||
llvm::Constant* definit = gIR->context().getConstantStruct(constants, packed);
|
||||
#if 0
|
||||
IF_LOG Logger::cout() << "final default initializer: " << *definit << std::endl;
|
||||
#endif
|
||||
@@ -384,7 +384,7 @@ LLConstant * IrStruct::createStructInitializer(StructInitializer * si)
|
||||
|
||||
// build constant
|
||||
assert(!constants.empty());
|
||||
llvm::Constant* c = llvm::ConstantStruct::get(&constants[0], constants.size(), packed);
|
||||
llvm::Constant* c = gIR->context().getConstantStruct(&constants[0], constants.size(), packed);
|
||||
IF_LOG Logger::cout() << "final struct initializer: " << *c << std::endl;
|
||||
return c;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user