mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +03:00
Adapt to new _d_newitemT template lowering for heap-allocations of structs
This commit is contained in:
parent
3ab72d8e52
commit
c5704c764d
4 changed files with 4 additions and 19 deletions
|
@ -91,15 +91,6 @@ LLValue *DtoNew(const Loc &loc, Type *newtype) {
|
||||||
return DtoBitCast(mem, DtoPtrToType(newtype), ".gc_mem");
|
return DtoBitCast(mem, DtoPtrToType(newtype), ".gc_mem");
|
||||||
}
|
}
|
||||||
|
|
||||||
LLValue *DtoNewStruct(const Loc &loc, TypeStruct *newtype) {
|
|
||||||
llvm::Function *fn = getRuntimeFunction(
|
|
||||||
loc, gIR->module,
|
|
||||||
newtype->isZeroInit(newtype->sym->loc) ? "_d_newitemT" : "_d_newitemiT");
|
|
||||||
LLConstant *ti = DtoTypeInfoOf(loc, newtype);
|
|
||||||
LLValue *mem = gIR->CreateCallOrInvoke(fn, ti, ".gc_struct");
|
|
||||||
return DtoBitCast(mem, DtoPtrToType(newtype), ".gc_struct");
|
|
||||||
}
|
|
||||||
|
|
||||||
void DtoDeleteMemory(const Loc &loc, DValue *ptr) {
|
void DtoDeleteMemory(const Loc &loc, DValue *ptr) {
|
||||||
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_delmemory");
|
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_delmemory");
|
||||||
LLValue *lval = (ptr->isLVal() ? DtoLVal(ptr) : makeLValue(loc, ptr));
|
LLValue *lval = (ptr->isLVal() ? DtoLVal(ptr) : makeLValue(loc, ptr));
|
||||||
|
|
|
@ -30,7 +30,6 @@ llvm::LLVMContext& getGlobalContext();
|
||||||
|
|
||||||
// dynamic memory helpers
|
// dynamic memory helpers
|
||||||
LLValue *DtoNew(const Loc &loc, Type *newtype);
|
LLValue *DtoNew(const Loc &loc, Type *newtype);
|
||||||
LLValue *DtoNewStruct(const Loc &loc, TypeStruct *newtype);
|
|
||||||
void DtoDeleteMemory(const Loc &loc, DValue *ptr);
|
void DtoDeleteMemory(const Loc &loc, DValue *ptr);
|
||||||
void DtoDeleteStruct(const Loc &loc, DValue *ptr);
|
void DtoDeleteStruct(const Loc &loc, DValue *ptr);
|
||||||
void DtoDeleteClass(const Loc &loc, DValue *inst);
|
void DtoDeleteClass(const Loc &loc, DValue *inst);
|
||||||
|
|
|
@ -89,8 +89,7 @@ static void checkForImplicitGCCall(const Loc &loc, const char *name) {
|
||||||
"_d_newarrayU",
|
"_d_newarrayU",
|
||||||
"_d_newclass",
|
"_d_newclass",
|
||||||
"_d_allocclass",
|
"_d_allocclass",
|
||||||
"_d_newitemT",
|
// TODO: _d_newitemT instantiations
|
||||||
"_d_newitemiT",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (binary_search(&GCNAMES[0],
|
if (binary_search(&GCNAMES[0],
|
||||||
|
@ -618,11 +617,6 @@ static void buildRuntimeModule() {
|
||||||
createFwdDecl(LINK::c, throwableTy, {"_d_newThrowable"}, {classInfoTy},
|
createFwdDecl(LINK::c, throwableTy, {"_d_newThrowable"}, {classInfoTy},
|
||||||
{STCconst});
|
{STCconst});
|
||||||
|
|
||||||
// void* _d_newitemT (TypeInfo ti)
|
|
||||||
// void* _d_newitemiT(TypeInfo ti)
|
|
||||||
createFwdDecl(LINK::c, voidPtrTy, {"_d_newitemT", "_d_newitemiT"},
|
|
||||||
{typeInfoTy}, {0});
|
|
||||||
|
|
||||||
// void _d_delarray_t(void[]* p, const TypeInfo_Struct ti)
|
// void _d_delarray_t(void[]* p, const TypeInfo_Struct ti)
|
||||||
createFwdDecl(LINK::c, voidTy, {"_d_delarray_t"},
|
createFwdDecl(LINK::c, voidTy, {"_d_delarray_t"},
|
||||||
{voidArrayPtrTy, structTypeInfoTy}, {0, STCconst});
|
{voidArrayPtrTy, structTypeInfoTy}, {0, STCconst});
|
||||||
|
|
|
@ -1549,8 +1549,9 @@ public:
|
||||||
|
|
||||||
TypeStruct *ts = static_cast<TypeStruct *>(ntype);
|
TypeStruct *ts = static_cast<TypeStruct *>(ntype);
|
||||||
|
|
||||||
// allocate
|
// allocate (via _d_newitemT template lowering)
|
||||||
LLValue *mem = DtoNewStruct(e->loc, ts);
|
assert(e->lowering);
|
||||||
|
LLValue *mem = DtoRVal(e->lowering);
|
||||||
|
|
||||||
if (!e->member && e->arguments) {
|
if (!e->member && e->arguments) {
|
||||||
IF_LOG Logger::println("Constructing using literal");
|
IF_LOG Logger::println("Constructing using literal");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue