mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-13 14:36:18 +03:00
parent
9d4c65270f
commit
660cefaaf6
1 changed files with 7 additions and 15 deletions
|
@ -62,8 +62,7 @@ Type *getTypeInfoType(Type *t, Scope *sc);
|
||||||
|
|
||||||
LLValue *DtoNew(Loc &loc, Type *newtype) {
|
LLValue *DtoNew(Loc &loc, Type *newtype) {
|
||||||
// get runtime function
|
// get runtime function
|
||||||
llvm::Function *fn =
|
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_allocmemoryT");
|
||||||
getRuntimeFunction(loc, gIR->module, "_d_allocmemoryT");
|
|
||||||
// get type info
|
// get type info
|
||||||
LLConstant *ti = DtoTypeInfoOf(newtype);
|
LLConstant *ti = DtoTypeInfoOf(newtype);
|
||||||
assert(isaPointer(ti));
|
assert(isaPointer(ti));
|
||||||
|
@ -83,16 +82,14 @@ LLValue *DtoNewStruct(Loc &loc, TypeStruct *newtype) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoDeleteMemory(Loc &loc, DValue *ptr) {
|
void DtoDeleteMemory(Loc &loc, DValue *ptr) {
|
||||||
llvm::Function *fn =
|
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_delmemory");
|
||||||
getRuntimeFunction(loc, gIR->module, "_d_delmemory");
|
|
||||||
LLValue *lval = (ptr->isLVal() ? ptr->getLVal() : makeLValue(loc, ptr));
|
LLValue *lval = (ptr->isLVal() ? ptr->getLVal() : makeLValue(loc, ptr));
|
||||||
gIR->CreateCallOrInvoke(
|
gIR->CreateCallOrInvoke(
|
||||||
fn, DtoBitCast(lval, fn->getFunctionType()->getParamType(0)));
|
fn, DtoBitCast(lval, fn->getFunctionType()->getParamType(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoDeleteStruct(Loc &loc, DValue *ptr) {
|
void DtoDeleteStruct(Loc &loc, DValue *ptr) {
|
||||||
llvm::Function *fn =
|
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_delstruct");
|
||||||
getRuntimeFunction(loc, gIR->module, "_d_delstruct");
|
|
||||||
LLValue *lval = (ptr->isLVal() ? ptr->getLVal() : makeLValue(loc, ptr));
|
LLValue *lval = (ptr->isLVal() ? ptr->getLVal() : makeLValue(loc, ptr));
|
||||||
gIR->CreateCallOrInvoke(
|
gIR->CreateCallOrInvoke(
|
||||||
fn, DtoBitCast(lval, fn->getFunctionType()->getParamType(0)),
|
fn, DtoBitCast(lval, fn->getFunctionType()->getParamType(0)),
|
||||||
|
@ -101,24 +98,21 @@ void DtoDeleteStruct(Loc &loc, DValue *ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoDeleteClass(Loc &loc, DValue *inst) {
|
void DtoDeleteClass(Loc &loc, DValue *inst) {
|
||||||
llvm::Function *fn =
|
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_delclass");
|
||||||
getRuntimeFunction(loc, gIR->module, "_d_delclass");
|
|
||||||
LLValue *lval = (inst->isLVal() ? inst->getLVal() : makeLValue(loc, inst));
|
LLValue *lval = (inst->isLVal() ? inst->getLVal() : makeLValue(loc, inst));
|
||||||
gIR->CreateCallOrInvoke(
|
gIR->CreateCallOrInvoke(
|
||||||
fn, DtoBitCast(lval, fn->getFunctionType()->getParamType(0)));
|
fn, DtoBitCast(lval, fn->getFunctionType()->getParamType(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoDeleteInterface(Loc &loc, DValue *inst) {
|
void DtoDeleteInterface(Loc &loc, DValue *inst) {
|
||||||
llvm::Function *fn =
|
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_delinterface");
|
||||||
getRuntimeFunction(loc, gIR->module, "_d_delinterface");
|
|
||||||
LLValue *lval = (inst->isLVal() ? inst->getLVal() : makeLValue(loc, inst));
|
LLValue *lval = (inst->isLVal() ? inst->getLVal() : makeLValue(loc, inst));
|
||||||
gIR->CreateCallOrInvoke(
|
gIR->CreateCallOrInvoke(
|
||||||
fn, DtoBitCast(lval, fn->getFunctionType()->getParamType(0)));
|
fn, DtoBitCast(lval, fn->getFunctionType()->getParamType(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoDeleteArray(Loc &loc, DValue *arr) {
|
void DtoDeleteArray(Loc &loc, DValue *arr) {
|
||||||
llvm::Function *fn =
|
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_delarray_t");
|
||||||
getRuntimeFunction(loc, gIR->module, "_d_delarray_t");
|
|
||||||
llvm::FunctionType *fty = fn->getFunctionType();
|
llvm::FunctionType *fty = fn->getFunctionType();
|
||||||
|
|
||||||
// the TypeInfo argument must be null if the type has no dtor
|
// the TypeInfo argument must be null if the type has no dtor
|
||||||
|
@ -182,8 +176,7 @@ llvm::AllocaInst *DtoRawAlloca(LLType *lltype, size_t alignment,
|
||||||
|
|
||||||
LLValue *DtoGcMalloc(Loc &loc, LLType *lltype, const char *name) {
|
LLValue *DtoGcMalloc(Loc &loc, LLType *lltype, const char *name) {
|
||||||
// get runtime function
|
// get runtime function
|
||||||
llvm::Function *fn =
|
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_allocmemory");
|
||||||
getRuntimeFunction(loc, gIR->module, "_d_allocmemory");
|
|
||||||
// parameters
|
// parameters
|
||||||
LLValue *size = DtoConstSize_t(getTypeAllocSize(lltype));
|
LLValue *size = DtoConstSize_t(getTypeAllocSize(lltype));
|
||||||
// call runtime allocator
|
// call runtime allocator
|
||||||
|
@ -1373,7 +1366,6 @@ LLValue *makeLValue(Loc &loc, DValue *value) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void callPostblit(Loc &loc, Expression *exp, LLValue *val) {
|
void callPostblit(Loc &loc, Expression *exp, LLValue *val) {
|
||||||
|
|
||||||
Type *tb = exp->type->toBasetype();
|
Type *tb = exp->type->toBasetype();
|
||||||
if ((exp->op == TOKvar || exp->op == TOKdotvar || exp->op == TOKstar ||
|
if ((exp->op == TOKvar || exp->op == TOKdotvar || exp->op == TOKstar ||
|
||||||
exp->op == TOKthis || exp->op == TOKindex) &&
|
exp->op == TOKthis || exp->op == TOKindex) &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue