mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 00:55:49 +03:00
Add line number to error message of -nogc switch.
This was suggested by bearophile in the news group. It also changes all Loc objects to be passed by reference.
This commit is contained in:
parent
e74e511b9c
commit
45fca1f3b5
23 changed files with 195 additions and 189 deletions
10
gen/aa.cpp
10
gen/aa.cpp
|
@ -47,7 +47,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
|
||||||
// extern(C) void* _aaInX(AA aa*, TypeInfo keyti, void* pkey)
|
// extern(C) void* _aaInX(AA aa*, TypeInfo keyti, void* pkey)
|
||||||
|
|
||||||
// first get the runtime function
|
// first get the runtime function
|
||||||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, lvalue?"_aaGetX":"_aaInX");
|
llvm::Function* func = LLVM_D_GetRuntimeFunction(loc, gIR->module, lvalue?"_aaGetX":"_aaInX");
|
||||||
LLFunctionType* funcTy = func->getFunctionType();
|
LLFunctionType* funcTy = func->getFunctionType();
|
||||||
|
|
||||||
// aa param
|
// aa param
|
||||||
|
@ -104,7 +104,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
|
||||||
};
|
};
|
||||||
|
|
||||||
// call
|
// call
|
||||||
llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_bounds");
|
llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_bounds");
|
||||||
gIR->CreateCallOrInvoke(errorfn, args);
|
gIR->CreateCallOrInvoke(errorfn, args);
|
||||||
|
|
||||||
// the function does not return
|
// the function does not return
|
||||||
|
@ -129,7 +129,7 @@ DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key)
|
||||||
// extern(C) void* _aaInX(AA aa*, TypeInfo keyti, void* pkey)
|
// extern(C) void* _aaInX(AA aa*, TypeInfo keyti, void* pkey)
|
||||||
|
|
||||||
// first get the runtime function
|
// first get the runtime function
|
||||||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaInX");
|
llvm::Function* func = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_aaInX");
|
||||||
LLFunctionType* funcTy = func->getFunctionType();
|
LLFunctionType* funcTy = func->getFunctionType();
|
||||||
|
|
||||||
IF_LOG Logger::cout() << "_aaIn = " << *func << '\n';
|
IF_LOG Logger::cout() << "_aaIn = " << *func << '\n';
|
||||||
|
@ -174,7 +174,7 @@ DValue *DtoAARemove(Loc& loc, DValue* aa, DValue* key)
|
||||||
// extern(C) bool _aaDelX(AA aa, TypeInfo keyti, void* pkey)
|
// extern(C) bool _aaDelX(AA aa, TypeInfo keyti, void* pkey)
|
||||||
|
|
||||||
// first get the runtime function
|
// first get the runtime function
|
||||||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaDelX");
|
llvm::Function* func = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_aaDelX");
|
||||||
LLFunctionType* funcTy = func->getFunctionType();
|
LLFunctionType* funcTy = func->getFunctionType();
|
||||||
|
|
||||||
IF_LOG Logger::cout() << "_aaDel = " << *func << '\n';
|
IF_LOG Logger::cout() << "_aaDel = " << *func << '\n';
|
||||||
|
@ -210,7 +210,7 @@ LLValue* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r)
|
||||||
{
|
{
|
||||||
Type* t = l->getType()->toBasetype();
|
Type* t = l->getType()->toBasetype();
|
||||||
assert(t == r->getType()->toBasetype() && "aa equality is only defined for aas of same type");
|
assert(t == r->getType()->toBasetype() && "aa equality is only defined for aas of same type");
|
||||||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaEqual");
|
llvm::Function* func = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_aaEqual");
|
||||||
LLFunctionType* funcTy = func->getFunctionType();
|
LLFunctionType* funcTy = func->getFunctionType();
|
||||||
|
|
||||||
LLValue* aaval = DtoBitCast(l->getRVal(), funcTy->getParamType(1));
|
LLValue* aaval = DtoBitCast(l->getRVal(), funcTy->getParamType(1));
|
||||||
|
|
|
@ -199,7 +199,7 @@ bool arrayNeedsPostblit(Type *t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does array assignment (or initialization) from another array of the same element type.
|
// Does array assignment (or initialization) from another array of the same element type.
|
||||||
void DtoArrayAssign(DValue *array, DValue *value, int op)
|
void DtoArrayAssign(Loc& loc, DValue *array, DValue *value, int op)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoArrayAssign");
|
IF_LOG Logger::println("DtoArrayAssign");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -213,7 +213,7 @@ void DtoArrayAssign(DValue *array, DValue *value, int op)
|
||||||
assert(t->nextOf());
|
assert(t->nextOf());
|
||||||
Type *elemType = t->nextOf()->toBasetype();
|
Type *elemType = t->nextOf()->toBasetype();
|
||||||
|
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, op == TOKconstruct ? "_d_arrayctor" : "_d_arrayassign");
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, op == TOKconstruct ? "_d_arrayctor" : "_d_arrayassign");
|
||||||
LLValue* args[] = {
|
LLValue* args[] = {
|
||||||
DtoTypeInfoOf(elemType),
|
DtoTypeInfoOf(elemType),
|
||||||
DtoAggrPaint(DtoSlice(value), fn->getFunctionType()->getParamType(1)),
|
DtoAggrPaint(DtoSlice(value), fn->getFunctionType()->getParamType(1)),
|
||||||
|
@ -226,7 +226,7 @@ void DtoArrayAssign(DValue *array, DValue *value, int op)
|
||||||
|
|
||||||
// If op is TOKconstruct, does construction of an array;
|
// If op is TOKconstruct, does construction of an array;
|
||||||
// otherwise, does assignment to an array.
|
// otherwise, does assignment to an array.
|
||||||
void DtoArraySetAssign(Loc &loc, DValue *array, DValue *value, int op)
|
void DtoArraySetAssign(Loc& loc, DValue *array, DValue *value, int op)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoArraySetAssign");
|
IF_LOG Logger::println("DtoArraySetAssign");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -237,7 +237,7 @@ void DtoArraySetAssign(Loc &loc, DValue *array, DValue *value, int op)
|
||||||
LLValue *ptr = DtoArrayPtr(array);
|
LLValue *ptr = DtoArrayPtr(array);
|
||||||
LLValue *len = DtoArrayLen(array);
|
LLValue *len = DtoArrayLen(array);
|
||||||
|
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, op == TOKconstruct ? "_d_arraysetctor" : "_d_arraysetassign");
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, op == TOKconstruct ? "_d_arraysetctor" : "_d_arraysetassign");
|
||||||
LLValue* args[] = {
|
LLValue* args[] = {
|
||||||
DtoBitCast(ptr, getVoidPtrType()),
|
DtoBitCast(ptr, getVoidPtrType()),
|
||||||
DtoBitCast(makeLValue(loc, value), getVoidPtrType()),
|
DtoBitCast(makeLValue(loc, value), getVoidPtrType()),
|
||||||
|
@ -500,11 +500,11 @@ static LLValue* get_slice_ptr(DSliceValue* e, LLValue*& sz)
|
||||||
return DtoBitCast(e->ptr, getVoidPtrType());
|
return DtoBitCast(e->ptr, getVoidPtrType());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copySlice(LLValue* dstarr, LLValue* sz1, LLValue* srcarr, LLValue* sz2)
|
static void copySlice(Loc& loc, LLValue* dstarr, LLValue* sz1, LLValue* srcarr, LLValue* sz2)
|
||||||
{
|
{
|
||||||
if (global.params.useAssert || gIR->emitArrayBoundsChecks())
|
if (global.params.useAssert || gIR->emitArrayBoundsChecks())
|
||||||
{
|
{
|
||||||
LLValue* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_slice_copy");
|
LLValue* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_slice_copy");
|
||||||
gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, sz2);
|
gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, sz2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -516,7 +516,7 @@ static void copySlice(LLValue* dstarr, LLValue* sz1, LLValue* srcarr, LLValue* s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoArrayCopySlices(DSliceValue* dst, DSliceValue* src)
|
void DtoArrayCopySlices(Loc& loc, DSliceValue* dst, DSliceValue* src)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("ArrayCopySlices");
|
IF_LOG Logger::println("ArrayCopySlices");
|
||||||
|
|
||||||
|
@ -524,10 +524,10 @@ void DtoArrayCopySlices(DSliceValue* dst, DSliceValue* src)
|
||||||
LLValue* dstarr = get_slice_ptr(dst,sz1);
|
LLValue* dstarr = get_slice_ptr(dst,sz1);
|
||||||
LLValue* srcarr = get_slice_ptr(src,sz2);
|
LLValue* srcarr = get_slice_ptr(src,sz2);
|
||||||
|
|
||||||
copySlice(dstarr, sz1, srcarr, sz2);
|
copySlice(loc, dstarr, sz1, srcarr, sz2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src)
|
void DtoArrayCopyToSlice(Loc& loc, DSliceValue* dst, DValue* src)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("ArrayCopyToSlice");
|
IF_LOG Logger::println("ArrayCopyToSlice");
|
||||||
|
|
||||||
|
@ -538,7 +538,7 @@ void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src)
|
||||||
LLType* arrayelemty = voidToI8(DtoType(src->getType()->nextOf()->toBasetype()));
|
LLType* arrayelemty = voidToI8(DtoType(src->getType()->nextOf()->toBasetype()));
|
||||||
LLValue* sz2 = gIR->ir->CreateMul(DtoConstSize_t(getTypePaddedSize(arrayelemty)), DtoArrayLen(src), "tmp");
|
LLValue* sz2 = gIR->ir->CreateMul(DtoConstSize_t(getTypePaddedSize(arrayelemty)), DtoArrayLen(src), "tmp");
|
||||||
|
|
||||||
copySlice(dstarr, sz1, srcarr, sz2);
|
copySlice(loc, dstarr, sz1, srcarr, sz2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -618,7 +618,7 @@ DSliceValue* DtoNewDynArray(Loc& loc, Type* arrayType, DValue* dim, bool default
|
||||||
const char* fnname = defaultInit ?
|
const char* fnname = defaultInit ?
|
||||||
(zeroInit ? "_d_newarrayT" : "_d_newarrayiT") :
|
(zeroInit ? "_d_newarrayT" : "_d_newarrayiT") :
|
||||||
"_d_newarrayvT";
|
"_d_newarrayvT";
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname);
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, fnname);
|
||||||
|
|
||||||
// call allocator
|
// call allocator
|
||||||
LLValue* newArray = gIR->CreateCallOrInvoke2(fn, arrayTypeInfo, arrayLen, ".gc_mem").getInstruction();
|
LLValue* newArray = gIR->CreateCallOrInvoke2(fn, arrayTypeInfo, arrayLen, ".gc_mem").getInstruction();
|
||||||
|
@ -647,7 +647,7 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size
|
||||||
|
|
||||||
const char* fnname = zeroInit ? "_d_newarraymT" : "_d_newarraymiT";
|
const char* fnname = zeroInit ? "_d_newarraymT" : "_d_newarraymiT";
|
||||||
|
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname);
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, fnname);
|
||||||
|
|
||||||
std::vector<LLValue*> args;
|
std::vector<LLValue*> args;
|
||||||
args.reserve(ndims+2);
|
args.reserve(ndims+2);
|
||||||
|
@ -667,7 +667,7 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, LLValue* newdim)
|
DSliceValue* DtoResizeDynArray(Loc& loc, Type* arrayType, DValue* array, LLValue* newdim)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoResizeDynArray : %s", arrayType->toChars());
|
IF_LOG Logger::println("DtoResizeDynArray : %s", arrayType->toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -681,7 +681,7 @@ DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, LLValue* newdim)
|
||||||
bool zeroInit = arrayType->toBasetype()->nextOf()->isZeroInit();
|
bool zeroInit = arrayType->toBasetype()->nextOf()->isZeroInit();
|
||||||
|
|
||||||
// call runtime
|
// call runtime
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, zeroInit ? "_d_arraysetlengthT" : "_d_arraysetlengthiT" );
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, zeroInit ? "_d_arraysetlengthT" : "_d_arraysetlengthiT" );
|
||||||
|
|
||||||
LLValue* args[] = {
|
LLValue* args[] = {
|
||||||
DtoTypeInfoOf(arrayType),
|
DtoTypeInfoOf(arrayType),
|
||||||
|
@ -708,7 +708,7 @@ void DtoCatAssignElement(Loc& loc, Type* arrayType, DValue* array, Expression* e
|
||||||
// otherwise a ~= a[$-i] won't work correctly
|
// otherwise a ~= a[$-i] won't work correctly
|
||||||
DValue *expVal = exp->toElem(gIR);
|
DValue *expVal = exp->toElem(gIR);
|
||||||
|
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arrayappendcTX");
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_arrayappendcTX");
|
||||||
LLValue* args[] = {
|
LLValue* args[] = {
|
||||||
DtoTypeInfoOf(arrayType),
|
DtoTypeInfoOf(arrayType),
|
||||||
DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(1)),
|
DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(1)),
|
||||||
|
@ -726,14 +726,14 @@ void DtoCatAssignElement(Loc& loc, Type* arrayType, DValue* array, Expression* e
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DSliceValue* DtoCatAssignArray(DValue* arr, Expression* exp)
|
DSliceValue* DtoCatAssignArray(Loc& loc, DValue* arr, Expression* exp)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoCatAssignArray");
|
IF_LOG Logger::println("DtoCatAssignArray");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
Type *arrayType = arr->getType();
|
Type *arrayType = arr->getType();
|
||||||
|
|
||||||
// Prepare arguments
|
// Prepare arguments
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arrayappendT");
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_arrayappendT");
|
||||||
LLSmallVector<LLValue*,3> args;
|
LLSmallVector<LLValue*,3> args;
|
||||||
// TypeInfo ti
|
// TypeInfo ti
|
||||||
args.push_back(DtoTypeInfoOf(arrayType));
|
args.push_back(DtoTypeInfoOf(arrayType));
|
||||||
|
@ -752,7 +752,7 @@ DSliceValue* DtoCatAssignArray(DValue* arr, Expression* exp)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DSliceValue* DtoCatArrays(Type* arrayType, Expression* exp1, Expression* exp2)
|
DSliceValue* DtoCatArrays(Loc& loc, Type* arrayType, Expression* exp1, Expression* exp2)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoCatAssignArray");
|
IF_LOG Logger::println("DtoCatAssignArray");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -762,7 +762,7 @@ DSliceValue* DtoCatArrays(Type* arrayType, Expression* exp1, Expression* exp2)
|
||||||
|
|
||||||
if (exp1->op == TOKcat)
|
if (exp1->op == TOKcat)
|
||||||
{ // handle multiple concat
|
{ // handle multiple concat
|
||||||
fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arraycatnT");
|
fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_arraycatnT");
|
||||||
|
|
||||||
args.push_back(DtoSlicePtr(exp2->toElem(gIR)));
|
args.push_back(DtoSlicePtr(exp2->toElem(gIR)));
|
||||||
CatExp *ce = static_cast<CatExp*>(exp1);
|
CatExp *ce = static_cast<CatExp*>(exp1);
|
||||||
|
@ -782,7 +782,7 @@ DSliceValue* DtoCatArrays(Type* arrayType, Expression* exp1, Expression* exp2)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arraycatT");
|
fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_arraycatT");
|
||||||
|
|
||||||
// TypeInfo ti
|
// TypeInfo ti
|
||||||
args.push_back(DtoTypeInfoOf(arrayType));
|
args.push_back(DtoTypeInfoOf(arrayType));
|
||||||
|
@ -802,13 +802,13 @@ DSliceValue* DtoCatArrays(Type* arrayType, Expression* exp1, Expression* exp2)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DSliceValue* DtoAppendDChar(DValue* arr, Expression* exp, const char *func)
|
DSliceValue* DtoAppendDChar(Loc& loc, DValue* arr, Expression* exp, const char *func)
|
||||||
{
|
{
|
||||||
Type *arrayType = arr->getType();
|
Type *arrayType = arr->getType();
|
||||||
DValue* valueToAppend = exp->toElem(gIR);
|
DValue* valueToAppend = exp->toElem(gIR);
|
||||||
|
|
||||||
// Prepare arguments
|
// Prepare arguments
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, func);
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, func);
|
||||||
LLValue* args[] = {
|
LLValue* args[] = {
|
||||||
// ref string x
|
// ref string x
|
||||||
DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0)),
|
DtoBitCast(arr->getLVal(), fn->getFunctionType()->getParamType(0)),
|
||||||
|
@ -824,20 +824,20 @@ DSliceValue* DtoAppendDChar(DValue* arr, Expression* exp, const char *func)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DSliceValue* DtoAppendDCharToString(DValue* arr, Expression* exp)
|
DSliceValue* DtoAppendDCharToString(Loc& loc, DValue* arr, Expression* exp)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoAppendDCharToString");
|
IF_LOG Logger::println("DtoAppendDCharToString");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
return DtoAppendDChar(arr, exp, "_d_arrayappendcd");
|
return DtoAppendDChar(loc, arr, exp, "_d_arrayappendcd");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DSliceValue* DtoAppendDCharToUnicodeString(DValue* arr, Expression* exp)
|
DSliceValue* DtoAppendDCharToUnicodeString(Loc& loc, DValue* arr, Expression* exp)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoAppendDCharToUnicodeString");
|
IF_LOG Logger::println("DtoAppendDCharToUnicodeString");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
return DtoAppendDChar(arr, exp, "_d_arrayappendwd");
|
return DtoAppendDChar(loc, arr, exp, "_d_arrayappendwd");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -845,7 +845,7 @@ DSliceValue* DtoAppendDCharToUnicodeString(DValue* arr, Expression* exp)
|
||||||
static LLValue* DtoArrayEqCmp_impl(Loc& loc, const char* func, DValue* l, DValue* r, bool useti)
|
static LLValue* DtoArrayEqCmp_impl(Loc& loc, const char* func, DValue* l, DValue* r, bool useti)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("comparing arrays");
|
IF_LOG Logger::println("comparing arrays");
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, func);
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, func);
|
||||||
assert(fn);
|
assert(fn);
|
||||||
|
|
||||||
// find common dynamic array type
|
// find common dynamic array type
|
||||||
|
@ -907,7 +907,7 @@ LLValue* DtoArrayCompare(Loc& loc, TOK op, DValue* l, DValue* r)
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
LLValue* DtoArrayCastLength(LLValue* len, LLType* elemty, LLType* newelemty)
|
LLValue* DtoArrayCastLength(Loc& loc, LLValue* len, LLType* elemty, LLType* newelemty)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoArrayCastLength");
|
IF_LOG Logger::println("DtoArrayCastLength");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -927,7 +927,7 @@ LLValue* DtoArrayCastLength(LLValue* len, LLType* elemty, LLType* newelemty)
|
||||||
LLConstantInt::get(DtoSize_t(), nsz, false)
|
LLConstantInt::get(DtoSize_t(), nsz, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_cast_len");
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_cast_len");
|
||||||
return gIR->CreateCallOrInvoke(fn, args, "tmp").getInstruction();
|
return gIR->CreateCallOrInvoke(fn, args, "tmp").getInstruction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1057,13 +1057,13 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to)
|
||||||
uinteger_t len = static_cast<TypeSArray*>(fromtype)->dim->toUInteger();
|
uinteger_t len = static_cast<TypeSArray*>(fromtype)->dim->toUInteger();
|
||||||
rval2 = LLConstantInt::get(DtoSize_t(), len, false);
|
rval2 = LLConstantInt::get(DtoSize_t(), len, false);
|
||||||
if (fromtype->nextOf()->size() != totype->nextOf()->size())
|
if (fromtype->nextOf()->size() != totype->nextOf()->size())
|
||||||
rval2 = DtoArrayCastLength(rval2, ety, ptrty->getContainedType(0));
|
rval2 = DtoArrayCastLength(loc, rval2, ety, ptrty->getContainedType(0));
|
||||||
rval = DtoBitCast(uval, ptrty);
|
rval = DtoBitCast(uval, ptrty);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rval2 = DtoArrayLen(u);
|
rval2 = DtoArrayLen(u);
|
||||||
if (fromtype->nextOf()->size() != totype->nextOf()->size())
|
if (fromtype->nextOf()->size() != totype->nextOf()->size())
|
||||||
rval2 = DtoArrayCastLength(rval2, ety, ptrty->getContainedType(0));
|
rval2 = DtoArrayCastLength(loc, rval2, ety, ptrty->getContainedType(0));
|
||||||
|
|
||||||
rval = DtoArrayPtr(u);
|
rval = DtoArrayPtr(u);
|
||||||
rval = DtoBitCast(rval, ptrty);
|
rval = DtoBitCast(rval, ptrty);
|
||||||
|
@ -1178,7 +1178,7 @@ void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, DValue* lowerBoun
|
||||||
args.push_back(c);
|
args.push_back(c);
|
||||||
|
|
||||||
// call
|
// call
|
||||||
llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_bounds");
|
llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_bounds");
|
||||||
gIR->CreateCallOrInvoke(errorfn, args);
|
gIR->CreateCallOrInvoke(errorfn, args);
|
||||||
|
|
||||||
// the function does not return
|
// the function does not return
|
||||||
|
|
20
gen/arrays.h
20
gen/arrays.h
|
@ -45,26 +45,26 @@ llvm::Constant* arrayLiteralToConst(IRState* p, ArrayLiteralExp* ale);
|
||||||
/// dstMem is expected to be a pointer to the array allocation.
|
/// dstMem is expected to be a pointer to the array allocation.
|
||||||
void initializeArrayLiteral(IRState* p, ArrayLiteralExp* ale, LLValue* dstMem);
|
void initializeArrayLiteral(IRState* p, ArrayLiteralExp* ale, LLValue* dstMem);
|
||||||
|
|
||||||
void DtoArrayCopySlices(DSliceValue* dst, DSliceValue* src);
|
void DtoArrayCopySlices(Loc& loc, DSliceValue* dst, DSliceValue* src);
|
||||||
void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src);
|
void DtoArrayCopyToSlice(Loc& loc, DSliceValue* dst, DValue* src);
|
||||||
|
|
||||||
void DtoArrayInit(Loc& loc, DValue* array, DValue* value, int op);
|
void DtoArrayInit(Loc& loc, DValue* array, DValue* value, int op);
|
||||||
Type *DtoArrayElementType(Type *arrayType);
|
Type *DtoArrayElementType(Type *arrayType);
|
||||||
bool arrayNeedsPostblit(Type *t);
|
bool arrayNeedsPostblit(Type *t);
|
||||||
void DtoArrayAssign(DValue *from, DValue *to, int op);
|
void DtoArrayAssign(Loc& loc, DValue *from, DValue *to, int op);
|
||||||
void DtoArraySetAssign(Loc &loc, DValue *array, DValue *value, int op);
|
void DtoArraySetAssign(Loc& loc, DValue *array, DValue *value, int op);
|
||||||
void DtoSetArray(DValue* array, LLValue* dim, LLValue* ptr);
|
void DtoSetArray(DValue* array, LLValue* dim, LLValue* ptr);
|
||||||
void DtoSetArrayToNull(LLValue* v);
|
void DtoSetArrayToNull(LLValue* v);
|
||||||
|
|
||||||
DSliceValue* DtoNewDynArray(Loc& loc, Type* arrayType, DValue* dim, bool defaultInit=true);
|
DSliceValue* DtoNewDynArray(Loc& loc, Type* arrayType, DValue* dim, bool defaultInit=true);
|
||||||
DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size_t ndims, bool defaultInit=true);
|
DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size_t ndims, bool defaultInit=true);
|
||||||
DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, llvm::Value* newdim);
|
DSliceValue* DtoResizeDynArray(Loc& loc, Type* arrayType, DValue* array, llvm::Value* newdim);
|
||||||
|
|
||||||
void DtoCatAssignElement(Loc& loc, Type* type, DValue* arr, Expression* exp);
|
void DtoCatAssignElement(Loc& loc, Type* type, DValue* arr, Expression* exp);
|
||||||
DSliceValue* DtoCatAssignArray(DValue* arr, Expression* exp);
|
DSliceValue* DtoCatAssignArray(Loc& loc, DValue* arr, Expression* exp);
|
||||||
DSliceValue* DtoCatArrays(Type* type, Expression* e1, Expression* e2);
|
DSliceValue* DtoCatArrays(Loc& loc, Type* type, Expression* e1, Expression* e2);
|
||||||
DSliceValue* DtoAppendDCharToString(DValue* arr, Expression* exp);
|
DSliceValue* DtoAppendDCharToString(Loc& loc, DValue* arr, Expression* exp);
|
||||||
DSliceValue* DtoAppendDCharToUnicodeString(DValue* arr, Expression* exp);
|
DSliceValue* DtoAppendDCharToUnicodeString(Loc& loc, DValue* arr, Expression* exp);
|
||||||
|
|
||||||
void DtoStaticArrayCopy(LLValue* dst, LLValue* src);
|
void DtoStaticArrayCopy(LLValue* dst, LLValue* src);
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ LLValue* DtoArrayCompare(Loc& loc, TOK op, DValue* l, DValue* r);
|
||||||
|
|
||||||
LLValue* DtoDynArrayIs(TOK op, DValue* l, DValue* r);
|
LLValue* DtoDynArrayIs(TOK op, DValue* l, DValue* r);
|
||||||
|
|
||||||
LLValue* DtoArrayCastLength(LLValue* len, LLType* elemty, LLType* newelemty);
|
LLValue* DtoArrayCastLength(Loc& loc, LLValue* len, LLType* elemty, LLType* newelemty);
|
||||||
|
|
||||||
LLValue* DtoArrayLen(DValue* v);
|
LLValue* DtoArrayLen(DValue* v);
|
||||||
LLValue* DtoArrayPtr(DValue* v);
|
LLValue* DtoArrayPtr(DValue* v);
|
||||||
|
|
|
@ -108,7 +108,7 @@ DValue* DtoBinRem(Type* targettype, DValue* lhs, DValue* rhs)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
LLValue* DtoBinNumericEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op)
|
LLValue* DtoBinNumericEquals(Loc& loc, DValue* lhs, DValue* rhs, TOK op)
|
||||||
{
|
{
|
||||||
assert(op == TOKequal || op == TOKnotequal ||
|
assert(op == TOKequal || op == TOKnotequal ||
|
||||||
op == TOKidentity || op == TOKnotidentity);
|
op == TOKidentity || op == TOKnotidentity);
|
||||||
|
@ -134,7 +134,7 @@ LLValue* DtoBinNumericEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
LLValue* DtoBinFloatsEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op)
|
LLValue* DtoBinFloatsEquals(Loc& loc, DValue* lhs, DValue* rhs, TOK op)
|
||||||
{
|
{
|
||||||
LLValue* res = 0;
|
LLValue* res = 0;
|
||||||
if (op == TOKequal) {
|
if (op == TOKequal) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ void DtoResolveClass(ClassDeclaration* cd)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DValue* DtoNewClass(Loc loc, TypeClass* tc, NewExp* newexp)
|
DValue* DtoNewClass(Loc& loc, TypeClass* tc, NewExp* newexp)
|
||||||
{
|
{
|
||||||
// resolve type
|
// resolve type
|
||||||
DtoResolveClass(tc->sym);
|
DtoResolveClass(tc->sym);
|
||||||
|
@ -105,7 +105,7 @@ DValue* DtoNewClass(Loc loc, TypeClass* tc, NewExp* newexp)
|
||||||
// default allocator
|
// default allocator
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_newclass");
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_newclass");
|
||||||
LLConstant* ci = DtoBitCast(tc->sym->ir.irAggr->getClassInfoSymbol(), DtoType(Type::typeinfoclass->type));
|
LLConstant* ci = DtoBitCast(tc->sym->ir.irAggr->getClassInfoSymbol(), DtoType(Type::typeinfoclass->type));
|
||||||
mem = gIR->CreateCallOrInvoke(fn, ci, ".newclass_gc_alloc").getInstruction();
|
mem = gIR->CreateCallOrInvoke(fn, ci, ".newclass_gc_alloc").getInstruction();
|
||||||
mem = DtoBitCast(mem, DtoType(tc), ".newclass_gc");
|
mem = DtoBitCast(mem, DtoType(tc), ".newclass_gc");
|
||||||
|
@ -185,10 +185,10 @@ void DtoInitClass(TypeClass* tc, LLValue* dst)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void DtoFinalizeClass(LLValue* inst)
|
void DtoFinalizeClass(Loc& loc, LLValue* inst)
|
||||||
{
|
{
|
||||||
// get runtime function
|
// get runtime function
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_callfinalizer");
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_callfinalizer");
|
||||||
// build args
|
// build args
|
||||||
LLValue* arg[] = {
|
LLValue* arg[] = {
|
||||||
DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")
|
DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")
|
||||||
|
@ -199,7 +199,7 @@ void DtoFinalizeClass(LLValue* inst)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DValue* DtoCastClass(DValue* val, Type* _to)
|
DValue* DtoCastClass(Loc& loc, DValue* val, Type* _to)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoCastClass(%s, %s)", val->getType()->toChars(), _to->toChars());
|
IF_LOG Logger::println("DtoCastClass(%s, %s)", val->getType()->toChars(), _to->toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -230,7 +230,6 @@ DValue* DtoCastClass(DValue* val, Type* _to)
|
||||||
v = gIR->ir->CreatePtrToInt(v, DtoSize_t(), "");
|
v = gIR->ir->CreatePtrToInt(v, DtoSize_t(), "");
|
||||||
// cast to the final int type
|
// cast to the final int type
|
||||||
DImValue im(Type::tsize_t, v);
|
DImValue im(Type::tsize_t, v);
|
||||||
Loc loc;
|
|
||||||
return DtoCastInt(loc, &im, _to);
|
return DtoCastInt(loc, &im, _to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +247,7 @@ DValue* DtoCastClass(DValue* val, Type* _to)
|
||||||
// interface -> interface
|
// interface -> interface
|
||||||
if (fc->sym->isInterfaceDeclaration()) {
|
if (fc->sym->isInterfaceDeclaration()) {
|
||||||
Logger::println("from interface");
|
Logger::println("from interface");
|
||||||
return DtoDynamicCastInterface(val, _to);
|
return DtoDynamicCastInterface(loc, val, _to);
|
||||||
}
|
}
|
||||||
// class -> interface - static cast
|
// class -> interface - static cast
|
||||||
else if (it->isBaseOf(fc->sym,NULL)) {
|
else if (it->isBaseOf(fc->sym,NULL)) {
|
||||||
|
@ -288,7 +287,7 @@ DValue* DtoCastClass(DValue* val, Type* _to)
|
||||||
// class -> interface
|
// class -> interface
|
||||||
else {
|
else {
|
||||||
Logger::println("from object");
|
Logger::println("from object");
|
||||||
return DtoDynamicCastObject(val, _to);
|
return DtoDynamicCastObject(loc, val, _to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// x -> class
|
// x -> class
|
||||||
|
@ -297,7 +296,7 @@ DValue* DtoCastClass(DValue* val, Type* _to)
|
||||||
// interface -> class
|
// interface -> class
|
||||||
if (fc->sym->isInterfaceDeclaration()) {
|
if (fc->sym->isInterfaceDeclaration()) {
|
||||||
Logger::println("interface cast");
|
Logger::println("interface cast");
|
||||||
return DtoDynamicCastInterface(val, _to);
|
return DtoDynamicCastInterface(loc, val, _to);
|
||||||
}
|
}
|
||||||
// class -> class - static down cast
|
// class -> class - static down cast
|
||||||
else if (tc->sym->isBaseOf(fc->sym,NULL)) {
|
else if (tc->sym->isBaseOf(fc->sym,NULL)) {
|
||||||
|
@ -309,14 +308,14 @@ DValue* DtoCastClass(DValue* val, Type* _to)
|
||||||
// class -> class - dynamic up cast
|
// class -> class - dynamic up cast
|
||||||
else {
|
else {
|
||||||
Logger::println("dynamic up cast");
|
Logger::println("dynamic up cast");
|
||||||
return DtoDynamicCastObject(val, _to);
|
return DtoDynamicCastObject(loc, val, _to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DValue* DtoDynamicCastObject(DValue* val, Type* _to)
|
DValue* DtoDynamicCastObject(Loc& loc, DValue* val, Type* _to)
|
||||||
{
|
{
|
||||||
// call:
|
// call:
|
||||||
// Object _d_dynamic_cast(Object o, ClassInfo c)
|
// Object _d_dynamic_cast(Object o, ClassInfo c)
|
||||||
|
@ -324,7 +323,7 @@ DValue* DtoDynamicCastObject(DValue* val, Type* _to)
|
||||||
DtoResolveClass(ClassDeclaration::object);
|
DtoResolveClass(ClassDeclaration::object);
|
||||||
DtoResolveClass(Type::typeinfoclass);
|
DtoResolveClass(Type::typeinfoclass);
|
||||||
|
|
||||||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_dynamic_cast");
|
llvm::Function* func = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_dynamic_cast");
|
||||||
LLFunctionType* funcTy = func->getFunctionType();
|
LLFunctionType* funcTy = func->getFunctionType();
|
||||||
|
|
||||||
// Object o
|
// Object o
|
||||||
|
@ -353,12 +352,12 @@ DValue* DtoDynamicCastObject(DValue* val, Type* _to)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DValue* DtoCastInterfaceToObject(DValue* val, Type* to)
|
DValue* DtoCastInterfaceToObject(Loc& loc, DValue* val, Type* to)
|
||||||
{
|
{
|
||||||
// call:
|
// call:
|
||||||
// Object _d_toObject(void* p)
|
// Object _d_toObject(void* p)
|
||||||
|
|
||||||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_toObject");
|
llvm::Function* func = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_toObject");
|
||||||
LLFunctionType* funcTy = func->getFunctionType();
|
LLFunctionType* funcTy = func->getFunctionType();
|
||||||
|
|
||||||
// void* p
|
// void* p
|
||||||
|
@ -379,7 +378,7 @@ DValue* DtoCastInterfaceToObject(DValue* val, Type* to)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DValue* DtoDynamicCastInterface(DValue* val, Type* _to)
|
DValue* DtoDynamicCastInterface(Loc& loc, DValue* val, Type* _to)
|
||||||
{
|
{
|
||||||
// call:
|
// call:
|
||||||
// Object _d_interface_cast(void* p, ClassInfo c)
|
// Object _d_interface_cast(void* p, ClassInfo c)
|
||||||
|
@ -387,7 +386,7 @@ DValue* DtoDynamicCastInterface(DValue* val, Type* _to)
|
||||||
DtoResolveClass(ClassDeclaration::object);
|
DtoResolveClass(ClassDeclaration::object);
|
||||||
DtoResolveClass(Type::typeinfoclass);
|
DtoResolveClass(Type::typeinfoclass);
|
||||||
|
|
||||||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_interface_cast");
|
llvm::Function* func = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_interface_cast");
|
||||||
LLFunctionType* funcTy = func->getFunctionType();
|
LLFunctionType* funcTy = func->getFunctionType();
|
||||||
|
|
||||||
// void* p
|
// void* p
|
||||||
|
|
|
@ -39,15 +39,15 @@ void DtoDefineClass(ClassDeclaration* cd);
|
||||||
/// FIXME: this should be put into IrStruct and eventually IrClass.
|
/// FIXME: this should be put into IrStruct and eventually IrClass.
|
||||||
llvm::Constant* DtoDefineClassInfo(ClassDeclaration* cd);
|
llvm::Constant* DtoDefineClassInfo(ClassDeclaration* cd);
|
||||||
|
|
||||||
DValue* DtoNewClass(Loc loc, TypeClass* type, NewExp* newexp);
|
DValue* DtoNewClass(Loc& loc, TypeClass* type, NewExp* newexp);
|
||||||
void DtoInitClass(TypeClass* tc, llvm::Value* dst);
|
void DtoInitClass(TypeClass* tc, llvm::Value* dst);
|
||||||
void DtoFinalizeClass(llvm::Value* inst);
|
void DtoFinalizeClass(Loc& loc, llvm::Value* inst);
|
||||||
|
|
||||||
DValue* DtoCastClass(DValue* val, Type* to);
|
DValue* DtoCastClass(Loc& loc, DValue* val, Type* to);
|
||||||
DValue* DtoDynamicCastObject(DValue* val, Type* to);
|
DValue* DtoDynamicCastObject(Loc& loc, DValue* val, Type* to);
|
||||||
|
|
||||||
DValue* DtoCastInterfaceToObject(DValue* val, Type* to);
|
DValue* DtoCastInterfaceToObject(Loc& loc, DValue* val, Type* to);
|
||||||
DValue* DtoDynamicCastInterface(DValue* val, Type* to);
|
DValue* DtoDynamicCastInterface(Loc& loc, DValue* val, Type* to);
|
||||||
|
|
||||||
llvm::Value* DtoIndexClass(llvm::Value* src, ClassDeclaration* sd, VarDeclaration* vd);
|
llvm::Value* DtoIndexClass(llvm::Value* src, ClassDeclaration* sd, VarDeclaration* vd);
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ void ldc::DIBuilder::Declare(llvm::Value *var, llvm::DIVariable divar)
|
||||||
instr->setDebugLoc(IR->ir->getCurrentDebugLocation());
|
instr->setDebugLoc(IR->ir->getCurrentDebugLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIFile ldc::DIBuilder::CreateFile(Loc loc)
|
llvm::DIFile ldc::DIBuilder::CreateFile(Loc& loc)
|
||||||
{
|
{
|
||||||
llvm::SmallString<128> path(loc.filename ? loc.filename : "");
|
llvm::SmallString<128> path(loc.filename ? loc.filename : "");
|
||||||
llvm::sys::fs::make_absolute(path);
|
llvm::sys::fs::make_absolute(path);
|
||||||
|
@ -392,7 +392,8 @@ llvm::DIType ldc::DIBuilder::CreateArrayType(Type *type)
|
||||||
|
|
||||||
assert(t->ty == Tarray && "Only arrays allowed for debug info in DIBuilder::CreateArrayType");
|
assert(t->ty == Tarray && "Only arrays allowed for debug info in DIBuilder::CreateArrayType");
|
||||||
|
|
||||||
llvm::DIFile file = CreateFile(Loc(IR->dmodule, 0));
|
Loc loc(IR->dmodule, 0);
|
||||||
|
llvm::DIFile file = CreateFile(loc);
|
||||||
|
|
||||||
llvm::Value *elems[] = {
|
llvm::Value *elems[] = {
|
||||||
CreateMemberType(0, Type::tsize_t, file, "length", 0),
|
CreateMemberType(0, Type::tsize_t, file, "length", 0),
|
||||||
|
@ -458,7 +459,8 @@ ldc::DIFunctionType ldc::DIBuilder::CreateFunctionType(Type *type)
|
||||||
TypeFunction *t = static_cast<TypeFunction*>(type);
|
TypeFunction *t = static_cast<TypeFunction*>(type);
|
||||||
Type *retType = t->next;
|
Type *retType = t->next;
|
||||||
|
|
||||||
llvm::DIFile file = CreateFile(Loc(IR->dmodule, 0));
|
Loc loc(IR->dmodule, 0);
|
||||||
|
llvm::DIFile file = CreateFile(loc);
|
||||||
|
|
||||||
// Create "dummy" subroutine type for the return type
|
// Create "dummy" subroutine type for the return type
|
||||||
llvm::SmallVector<llvm::Value*, 16> Elts;
|
llvm::SmallVector<llvm::Value*, 16> Elts;
|
||||||
|
@ -472,7 +474,8 @@ ldc::DIFunctionType ldc::DIBuilder::CreateDelegateType(Type *type)
|
||||||
// FIXME: Implement
|
// FIXME: Implement
|
||||||
TypeDelegate *t = static_cast<TypeDelegate*>(type);
|
TypeDelegate *t = static_cast<TypeDelegate*>(type);
|
||||||
|
|
||||||
llvm::DIFile file = CreateFile(Loc(IR->dmodule, 0));
|
Loc loc(IR->dmodule, 0);
|
||||||
|
llvm::DIFile file = CreateFile(loc);
|
||||||
|
|
||||||
// Create "dummy" subroutine type for the return type
|
// Create "dummy" subroutine type for the return type
|
||||||
llvm::SmallVector<llvm::Value*, 16> Elts;
|
llvm::SmallVector<llvm::Value*, 16> Elts;
|
||||||
|
@ -607,7 +610,8 @@ llvm::DISubprogram ldc::DIBuilder::EmitSubProgramInternal(llvm::StringRef pretty
|
||||||
Logger::println("D to dwarf subprogram");
|
Logger::println("D to dwarf subprogram");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
llvm::DIFile file(CreateFile(Loc(IR->dmodule, 0)));
|
Loc loc(IR->dmodule, 0);
|
||||||
|
llvm::DIFile file(CreateFile(loc));
|
||||||
|
|
||||||
// Create "dummy" subroutine type for the return type
|
// Create "dummy" subroutine type for the return type
|
||||||
llvm::SmallVector<llvm::Value *, 1> Elts;
|
llvm::SmallVector<llvm::Value *, 1> Elts;
|
||||||
|
@ -656,7 +660,7 @@ void ldc::DIBuilder::EmitFuncEnd(FuncDeclaration *fd)
|
||||||
assert(static_cast<llvm::MDNode *>(fd->ir.irFunc->diSubprogram) != 0);
|
assert(static_cast<llvm::MDNode *>(fd->ir.irFunc->diSubprogram) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ldc::DIBuilder::EmitBlockStart(Loc loc)
|
void ldc::DIBuilder::EmitBlockStart(Loc& loc)
|
||||||
{
|
{
|
||||||
if (!global.params.symdebug)
|
if (!global.params.symdebug)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -113,7 +113,7 @@ public:
|
||||||
void EmitFuncEnd(FuncDeclaration *fd);
|
void EmitFuncEnd(FuncDeclaration *fd);
|
||||||
|
|
||||||
/// \brief Emits debug info for block start
|
/// \brief Emits debug info for block start
|
||||||
void EmitBlockStart(Loc loc);
|
void EmitBlockStart(Loc& loc);
|
||||||
|
|
||||||
/// \brief Emits debug info for block end
|
/// \brief Emits debug info for block end
|
||||||
void EmitBlockEnd();
|
void EmitBlockEnd();
|
||||||
|
@ -143,7 +143,7 @@ private:
|
||||||
void Declare(llvm::Value *var, llvm::DIVariable divar);
|
void Declare(llvm::Value *var, llvm::DIVariable divar);
|
||||||
void AddBaseFields(ClassDeclaration *sd, llvm::DIFile file,
|
void AddBaseFields(ClassDeclaration *sd, llvm::DIFile file,
|
||||||
std::vector<llvm::Value*> &elems);
|
std::vector<llvm::Value*> &elems);
|
||||||
llvm::DIFile CreateFile(Loc loc);
|
llvm::DIFile CreateFile(Loc& loc);
|
||||||
llvm::DIType CreateBasicType(Type *type);
|
llvm::DIType CreateBasicType(Type *type);
|
||||||
llvm::DIType CreateEnumType(Type *type);
|
llvm::DIType CreateEnumType(Type *type);
|
||||||
llvm::DIType CreatePointerType(Type *type);
|
llvm::DIType CreatePointerType(Type *type);
|
||||||
|
|
|
@ -39,7 +39,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl);
|
||||||
void DtoDefineFunction(FuncDeclaration* fd);
|
void DtoDefineFunction(FuncDeclaration* fd);
|
||||||
|
|
||||||
void DtoDefineNakedFunction(FuncDeclaration* fd);
|
void DtoDefineNakedFunction(FuncDeclaration* fd);
|
||||||
void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl);
|
void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc& loc, FuncDeclaration* fdecl);
|
||||||
|
|
||||||
DValue* DtoArgument(Parameter* fnarg, Expression* argexp);
|
DValue* DtoArgument(Parameter* fnarg, Expression* argexp);
|
||||||
void DtoVariadicArgument(Expression* argexp, llvm::Value* dst);
|
void DtoVariadicArgument(Expression* argexp, llvm::Value* dst);
|
||||||
|
|
|
@ -58,10 +58,10 @@ llvm::cl::opt<llvm::GlobalVariable::ThreadLocalMode> clThreadModel("fthread-mode
|
||||||
// DYNAMIC MEMORY HELPERS
|
// DYNAMIC MEMORY HELPERS
|
||||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
////////////////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
LLValue* DtoNew(Type* newtype)
|
LLValue* DtoNew(Loc& loc, Type* newtype)
|
||||||
{
|
{
|
||||||
// get runtime function
|
// get runtime function
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_allocmemoryT");
|
llvm::Function* fn = LLVM_D_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));
|
||||||
|
@ -71,20 +71,20 @@ LLValue* DtoNew(Type* newtype)
|
||||||
return DtoBitCast(mem, getPtrToType(i1ToI8(DtoType(newtype))), ".gc_mem");
|
return DtoBitCast(mem, getPtrToType(i1ToI8(DtoType(newtype))), ".gc_mem");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoDeleteMemory(LLValue* ptr)
|
void DtoDeleteMemory(Loc& loc, LLValue* ptr)
|
||||||
{
|
{
|
||||||
// get runtime function
|
// get runtime function
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delmemory");
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_delmemory");
|
||||||
// build args
|
// build args
|
||||||
LLValue* arg[] = { DtoBitCast(ptr, getVoidPtrType(), ".tmp") };
|
LLValue* arg[] = { DtoBitCast(ptr, getVoidPtrType(), ".tmp") };
|
||||||
// call
|
// call
|
||||||
gIR->CreateCallOrInvoke(fn, arg);
|
gIR->CreateCallOrInvoke(fn, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoDeleteClass(LLValue* inst)
|
void DtoDeleteClass(Loc& loc, LLValue* inst)
|
||||||
{
|
{
|
||||||
// get runtime function
|
// get runtime function
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delclass");
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_delclass");
|
||||||
// druntime wants a pointer to object
|
// druntime wants a pointer to object
|
||||||
LLValue *ptr = DtoRawAlloca(inst->getType(), 0, "objectPtr");
|
LLValue *ptr = DtoRawAlloca(inst->getType(), 0, "objectPtr");
|
||||||
DtoStore(inst, ptr);
|
DtoStore(inst, ptr);
|
||||||
|
@ -97,10 +97,10 @@ void DtoDeleteClass(LLValue* inst)
|
||||||
gIR->CreateCallOrInvoke(fn, arg);
|
gIR->CreateCallOrInvoke(fn, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoDeleteInterface(LLValue* inst)
|
void DtoDeleteInterface(Loc& loc, LLValue* inst)
|
||||||
{
|
{
|
||||||
// get runtime function
|
// get runtime function
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delinterface");
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_delinterface");
|
||||||
// build args
|
// build args
|
||||||
LLValue* arg[] = {
|
LLValue* arg[] = {
|
||||||
DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")
|
DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")
|
||||||
|
@ -109,10 +109,10 @@ void DtoDeleteInterface(LLValue* inst)
|
||||||
gIR->CreateCallOrInvoke(fn, arg);
|
gIR->CreateCallOrInvoke(fn, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoDeleteArray(DValue* arr)
|
void DtoDeleteArray(Loc& loc, DValue* arr)
|
||||||
{
|
{
|
||||||
// get runtime function
|
// get runtime function
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delarray_t");
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_delarray_t");
|
||||||
|
|
||||||
// build args
|
// build args
|
||||||
LLValue* arg[] = {
|
LLValue* arg[] = {
|
||||||
|
@ -155,10 +155,10 @@ llvm::AllocaInst* DtoRawAlloca(LLType* lltype, size_t alignment, const char* nam
|
||||||
return ai;
|
return ai;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLValue* DtoGcMalloc(LLType* lltype, const char* name)
|
LLValue* DtoGcMalloc(Loc& loc, LLType* lltype, const char* name)
|
||||||
{
|
{
|
||||||
// get runtime function
|
// get runtime function
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_allocmemory");
|
llvm::Function* fn = LLVM_D_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
|
||||||
|
@ -172,11 +172,11 @@ LLValue* DtoGcMalloc(LLType* lltype, const char* name)
|
||||||
// ASSERT HELPER
|
// ASSERT HELPER
|
||||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
////////////////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
void DtoAssert(Module* M, Loc loc, DValue* msg)
|
void DtoAssert(Module* M, Loc& loc, DValue* msg)
|
||||||
{
|
{
|
||||||
// func
|
// func
|
||||||
const char* fname = msg ? "_d_assert_msg" : "_d_assert";
|
const char* fname = msg ? "_d_assert_msg" : "_d_assert";
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname);
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, fname);
|
||||||
|
|
||||||
// Arguments
|
// Arguments
|
||||||
llvm::SmallVector<LLValue*, 3> args;
|
llvm::SmallVector<LLValue*, 3> args;
|
||||||
|
@ -239,7 +239,7 @@ LabelStatement* DtoLabelStatement(Identifier* ident)
|
||||||
/*////////////////////////////////////////////////////////////////////////////////////////
|
/*////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// GOTO HELPER
|
// GOTO HELPER
|
||||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
////////////////////////////////////////////////////////////////////////////////////////*/
|
||||||
void DtoGoto(Loc loc, Identifier* target, TryFinallyStatement* sourceFinally)
|
void DtoGoto(Loc& loc, Identifier* target, TryFinallyStatement* sourceFinally)
|
||||||
{
|
{
|
||||||
assert(!gIR->scopereturned());
|
assert(!gIR->scopereturned());
|
||||||
|
|
||||||
|
@ -276,9 +276,9 @@ void DtoGoto(Loc loc, Identifier* target, TryFinallyStatement* sourceFinally)
|
||||||
void EnclosingSynchro::emitCode(IRState * p)
|
void EnclosingSynchro::emitCode(IRState * p)
|
||||||
{
|
{
|
||||||
if (s->exp)
|
if (s->exp)
|
||||||
DtoLeaveMonitor(s->exp->toElem(p)->getRVal());
|
DtoLeaveMonitor(s->exp->loc, s->exp->toElem(p)->getRVal());
|
||||||
else
|
else
|
||||||
DtoLeaveCritical(s->llsync);
|
DtoLeaveCritical(s->loc, s->llsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -296,7 +296,7 @@ void EnclosingTryFinally::emitCode(IRState * p)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void DtoEnclosingHandlers(Loc loc, Statement* target)
|
void DtoEnclosingHandlers(Loc& loc, Statement* target)
|
||||||
{
|
{
|
||||||
// labels are a special case: they are not required to enclose the current scope
|
// labels are a special case: they are not required to enclose the current scope
|
||||||
// for them we use the enclosing scope handler as a reference point
|
// for them we use the enclosing scope handler as a reference point
|
||||||
|
@ -343,28 +343,28 @@ void DtoEnclosingHandlers(Loc loc, Statement* target)
|
||||||
// SYNCHRONIZED SECTION HELPERS
|
// SYNCHRONIZED SECTION HELPERS
|
||||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
////////////////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
void DtoEnterCritical(LLValue* g)
|
void DtoEnterCritical(Loc& loc, LLValue* g)
|
||||||
{
|
{
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_criticalenter");
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_criticalenter");
|
||||||
gIR->CreateCallOrInvoke(fn, g);
|
gIR->CreateCallOrInvoke(fn, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoLeaveCritical(LLValue* g)
|
void DtoLeaveCritical(Loc& loc, LLValue* g)
|
||||||
{
|
{
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_criticalexit");
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_criticalexit");
|
||||||
gIR->CreateCallOrInvoke(fn, g);
|
gIR->CreateCallOrInvoke(fn, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoEnterMonitor(LLValue* v)
|
void DtoEnterMonitor(Loc& loc, LLValue* v)
|
||||||
{
|
{
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorenter");
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_monitorenter");
|
||||||
v = DtoBitCast(v, fn->getFunctionType()->getParamType(0));
|
v = DtoBitCast(v, fn->getFunctionType()->getParamType(0));
|
||||||
gIR->CreateCallOrInvoke(fn, v);
|
gIR->CreateCallOrInvoke(fn, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoLeaveMonitor(LLValue* v)
|
void DtoLeaveMonitor(Loc& loc, LLValue* v)
|
||||||
{
|
{
|
||||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_monitorexit");
|
LLFunction* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_monitorexit");
|
||||||
v = DtoBitCast(v, fn->getFunctionType()->getParamType(0));
|
v = DtoBitCast(v, fn->getFunctionType()->getParamType(0));
|
||||||
gIR->CreateCallOrInvoke(fn, v);
|
gIR->CreateCallOrInvoke(fn, v);
|
||||||
}
|
}
|
||||||
|
@ -411,13 +411,13 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPostblit)
|
||||||
else if (op != -1 && op != TOKblit && !canSkipPostblit &&
|
else if (op != -1 && op != TOKblit && !canSkipPostblit &&
|
||||||
arrayNeedsPostblit(t)
|
arrayNeedsPostblit(t)
|
||||||
) {
|
) {
|
||||||
DtoArrayAssign(s, rhs, op);
|
DtoArrayAssign(loc, s, rhs, op);
|
||||||
}
|
}
|
||||||
else if (DSliceValue *s2 = rhs->isSlice()) {
|
else if (DSliceValue *s2 = rhs->isSlice()) {
|
||||||
DtoArrayCopySlices(s, s2);
|
DtoArrayCopySlices(loc, s, s2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DtoArrayCopyToSlice(s, rhs);
|
DtoArrayCopyToSlice(loc, s, rhs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// rhs is slice
|
// rhs is slice
|
||||||
|
@ -449,7 +449,7 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPostblit)
|
||||||
else if (op != -1 && op != TOKblit && !canSkipPostblit &&
|
else if (op != -1 && op != TOKblit && !canSkipPostblit &&
|
||||||
arrayNeedsPostblit(t)
|
arrayNeedsPostblit(t)
|
||||||
) {
|
) {
|
||||||
DtoArrayAssign(lhs, rhs, op);
|
DtoArrayAssign(loc, lhs, rhs, op);
|
||||||
}
|
}
|
||||||
// T[n] = T[n]
|
// T[n] = T[n]
|
||||||
else if (DtoType(lhs->getType()) == DtoType(rhs->getType())) {
|
else if (DtoType(lhs->getType()) == DtoType(rhs->getType())) {
|
||||||
|
@ -861,7 +861,7 @@ DValue* DtoCast(Loc& loc, DValue* val, Type* to)
|
||||||
return DtoCastFloat(loc, val, to);
|
return DtoCastFloat(loc, val, to);
|
||||||
}
|
}
|
||||||
else if (fromtype->ty == Tclass) {
|
else if (fromtype->ty == Tclass) {
|
||||||
return DtoCastClass(val, to);
|
return DtoCastClass(loc, val, to);
|
||||||
}
|
}
|
||||||
else if (fromtype->ty == Tarray || fromtype->ty == Tsarray) {
|
else if (fromtype->ty == Tarray || fromtype->ty == Tsarray) {
|
||||||
return DtoCastArray(loc, val, to);
|
return DtoCastArray(loc, val, to);
|
||||||
|
@ -1340,7 +1340,7 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr)
|
||||||
// INITIALIZER HELPERS
|
// INITIALIZER HELPERS
|
||||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
////////////////////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
LLConstant* DtoConstInitializer(Loc loc, Type* type, Initializer* init)
|
LLConstant* DtoConstInitializer(Loc& loc, Type* type, Initializer* init)
|
||||||
{
|
{
|
||||||
LLConstant* _init = 0; // may return zero
|
LLConstant* _init = 0; // may return zero
|
||||||
if (!init)
|
if (!init)
|
||||||
|
@ -1378,7 +1378,7 @@ LLConstant* DtoConstInitializer(Loc loc, Type* type, Initializer* init)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
LLConstant* DtoConstExpInit(Loc loc, Type* targetType, Expression* exp)
|
LLConstant* DtoConstExpInit(Loc& loc, Type* targetType, Expression* exp)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoConstExpInit(targetType = %s, exp = %s)",
|
IF_LOG Logger::println("DtoConstExpInit(targetType = %s, exp = %s)",
|
||||||
targetType->toChars(), exp->toChars());
|
targetType->toChars(), exp->toChars());
|
||||||
|
@ -1665,7 +1665,7 @@ 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();
|
||||||
|
@ -1757,7 +1757,7 @@ void tokToIcmpPred(TOK op, bool isUnsigned, llvm::ICmpInst::Predicate* outPred,
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
DValue* DtoSymbolAddress(const Loc& loc, Type* type, Declaration* decl)
|
DValue* DtoSymbolAddress(Loc& loc, Type* type, Declaration* decl)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoSymbolAddress ('%s' of type '%s')",
|
IF_LOG Logger::println("DtoSymbolAddress ('%s' of type '%s')",
|
||||||
decl->toChars(), decl->type->toChars());
|
decl->toChars(), decl->type->toChars());
|
||||||
|
@ -1927,7 +1927,7 @@ DValue* DtoSymbolAddress(const Loc& loc, Type* type, Declaration* decl)
|
||||||
llvm_unreachable("Unimplemented VarExp type");
|
llvm_unreachable("Unimplemented VarExp type");
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Constant* DtoConstSymbolAddress(const Loc& loc, Declaration* decl)
|
llvm::Constant* DtoConstSymbolAddress(Loc& loc, Declaration* decl)
|
||||||
{
|
{
|
||||||
// Make sure 'this' isn't needed.
|
// Make sure 'this' isn't needed.
|
||||||
// TODO: This check really does not belong here, should be moved to
|
// TODO: This check really does not belong here, should be moved to
|
||||||
|
@ -1969,7 +1969,7 @@ llvm::Constant* DtoConstSymbolAddress(const Loc& loc, Declaration* decl)
|
||||||
llvm_unreachable("Taking constant address not implemented.");
|
llvm_unreachable("Taking constant address not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::GlobalVariable* getOrCreateGlobal(Loc loc, llvm::Module& module,
|
llvm::GlobalVariable* getOrCreateGlobal(Loc& loc, llvm::Module& module,
|
||||||
llvm::Type* type, bool isConstant, llvm::GlobalValue::LinkageTypes linkage,
|
llvm::Type* type, bool isConstant, llvm::GlobalValue::LinkageTypes linkage,
|
||||||
llvm::Constant* init, llvm::StringRef name, bool isThreadLocal)
|
llvm::Constant* init, llvm::StringRef name, bool isThreadLocal)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,47 +44,47 @@ struct EnclosingSynchro : EnclosingHandler
|
||||||
|
|
||||||
|
|
||||||
// dynamic memory helpers
|
// dynamic memory helpers
|
||||||
LLValue* DtoNew(Type* newtype);
|
LLValue* DtoNew(Loc& loc, Type* newtype);
|
||||||
void DtoDeleteMemory(LLValue* ptr);
|
void DtoDeleteMemory(Loc& loc, LLValue* ptr);
|
||||||
void DtoDeleteClass(LLValue* inst);
|
void DtoDeleteClass(Loc& loc, LLValue* inst);
|
||||||
void DtoDeleteInterface(LLValue* inst);
|
void DtoDeleteInterface(Loc& loc, LLValue* inst);
|
||||||
void DtoDeleteArray(DValue* arr);
|
void DtoDeleteArray(Loc& loc, DValue* arr);
|
||||||
|
|
||||||
// emit an alloca
|
// emit an alloca
|
||||||
llvm::AllocaInst* DtoAlloca(Type* type, const char* name = "");
|
llvm::AllocaInst* DtoAlloca(Type* type, const char* name = "");
|
||||||
llvm::AllocaInst* DtoArrayAlloca(Type* type, unsigned arraysize, const char* name = "");
|
llvm::AllocaInst* DtoArrayAlloca(Type* type, unsigned arraysize, const char* name = "");
|
||||||
llvm::AllocaInst* DtoRawAlloca(LLType* lltype, size_t alignment, const char* name = "");
|
llvm::AllocaInst* DtoRawAlloca(LLType* lltype, size_t alignment, const char* name = "");
|
||||||
LLValue* DtoGcMalloc(LLType* lltype, const char* name = "");
|
LLValue* DtoGcMalloc(Loc& loc, LLType* lltype, const char* name = "");
|
||||||
|
|
||||||
// assertion generator
|
// assertion generator
|
||||||
void DtoAssert(Module* M, Loc loc, DValue* msg);
|
void DtoAssert(Module* M, Loc& loc, DValue* msg);
|
||||||
|
|
||||||
// return the LabelStatement from the current function with the given identifier or NULL if not found
|
// return the LabelStatement from the current function with the given identifier or NULL if not found
|
||||||
LabelStatement* DtoLabelStatement(Identifier* ident);
|
LabelStatement* DtoLabelStatement(Identifier* ident);
|
||||||
|
|
||||||
/// emits goto to LabelStatement with the target identifier
|
/// emits goto to LabelStatement with the target identifier
|
||||||
/// the sourceFinally is only used for error checking
|
/// the sourceFinally is only used for error checking
|
||||||
void DtoGoto(Loc loc, Identifier* target, TryFinallyStatement* sourceFinally);
|
void DtoGoto(Loc& loc, Identifier* target, TryFinallyStatement* sourceFinally);
|
||||||
|
|
||||||
// Generates IR for enclosing handlers between the current state and
|
// Generates IR for enclosing handlers between the current state and
|
||||||
// the scope created by the 'target' statement.
|
// the scope created by the 'target' statement.
|
||||||
void DtoEnclosingHandlers(Loc loc, Statement* target);
|
void DtoEnclosingHandlers(Loc& loc, Statement* target);
|
||||||
|
|
||||||
/// Enters a critical section.
|
/// Enters a critical section.
|
||||||
void DtoEnterCritical(LLValue* g);
|
void DtoEnterCritical(Loc& loc, LLValue* g);
|
||||||
/// leaves a critical section.
|
/// leaves a critical section.
|
||||||
void DtoLeaveCritical(LLValue* g);
|
void DtoLeaveCritical(Loc& loc, LLValue* g);
|
||||||
|
|
||||||
/// Enters a monitor lock.
|
/// Enters a monitor lock.
|
||||||
void DtoEnterMonitor(LLValue* v);
|
void DtoEnterMonitor(Loc& loc, LLValue* v);
|
||||||
/// Leaves a monitor lock.
|
/// Leaves a monitor lock.
|
||||||
void DtoLeaveMonitor(LLValue* v);
|
void DtoLeaveMonitor(Loc& loc, LLValue* v);
|
||||||
|
|
||||||
// basic operations
|
// basic operations
|
||||||
void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op = -1, bool canSkipPostblit = false);
|
void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op = -1, bool canSkipPostblit = false);
|
||||||
|
|
||||||
DValue* DtoSymbolAddress(const Loc& loc, Type* type, Declaration* decl);
|
DValue* DtoSymbolAddress(Loc& loc, Type* type, Declaration* decl);
|
||||||
llvm::Constant* DtoConstSymbolAddress(const Loc& loc,Declaration* decl);
|
llvm::Constant* DtoConstSymbolAddress(Loc& loc,Declaration* decl);
|
||||||
|
|
||||||
/// Create a null DValue.
|
/// Create a null DValue.
|
||||||
DValue* DtoNullValue(Type* t);
|
DValue* DtoNullValue(Type* t);
|
||||||
|
@ -118,8 +118,8 @@ DValue* DtoDeclarationExp(Dsymbol* declaration);
|
||||||
LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr = 0);
|
LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr = 0);
|
||||||
|
|
||||||
// initializer helpers
|
// initializer helpers
|
||||||
LLConstant* DtoConstInitializer(Loc loc, Type* type, Initializer* init);
|
LLConstant* DtoConstInitializer(Loc& loc, Type* type, Initializer* init);
|
||||||
LLConstant* DtoConstExpInit(Loc loc, Type* targetType, Expression* exp);
|
LLConstant* DtoConstExpInit(Loc& loc, Type* targetType, Expression* exp);
|
||||||
|
|
||||||
// getting typeinfo of type, base=true casts to object.TypeInfo
|
// getting typeinfo of type, base=true casts to object.TypeInfo
|
||||||
LLConstant* DtoTypeInfoOf(Type* ty, bool base=true);
|
LLConstant* DtoTypeInfoOf(Type* ty, bool base=true);
|
||||||
|
@ -132,8 +132,8 @@ DValue* DtoBinSub(DValue* lhs, DValue* rhs);
|
||||||
DValue* DtoBinMul(Type* resulttype, DValue* lhs, DValue* rhs);
|
DValue* DtoBinMul(Type* resulttype, DValue* lhs, DValue* rhs);
|
||||||
DValue* DtoBinDiv(Type* resulttype, DValue* lhs, DValue* rhs);
|
DValue* DtoBinDiv(Type* resulttype, DValue* lhs, DValue* rhs);
|
||||||
DValue* DtoBinRem(Type* resulttype, DValue* lhs, DValue* rhs);
|
DValue* DtoBinRem(Type* resulttype, DValue* lhs, DValue* rhs);
|
||||||
LLValue* DtoBinNumericEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op);
|
LLValue* DtoBinNumericEquals(Loc& loc, DValue* lhs, DValue* rhs, TOK op);
|
||||||
LLValue* DtoBinFloatsEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op);
|
LLValue* DtoBinFloatsEquals(Loc& loc, DValue* lhs, DValue* rhs, TOK op);
|
||||||
|
|
||||||
// target stuff
|
// target stuff
|
||||||
void findDefaultTarget();
|
void findDefaultTarget();
|
||||||
|
@ -145,7 +145,7 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s
|
||||||
bool hasUnalignedFields(Type* t);
|
bool hasUnalignedFields(Type* t);
|
||||||
|
|
||||||
///
|
///
|
||||||
DValue* DtoInlineAsmExpr(Loc loc, FuncDeclaration* fd, Expressions* arguments);
|
DValue* DtoInlineAsmExpr(Loc& loc, FuncDeclaration* fd, Expressions* arguments);
|
||||||
|
|
||||||
/// Create the IrModule if necessary and returns it.
|
/// Create the IrModule if necessary and returns it.
|
||||||
IrModule* getIrModule(Module* M);
|
IrModule* getIrModule(Module* M);
|
||||||
|
@ -159,7 +159,7 @@ size_t realignOffset(size_t offset, Type* type);
|
||||||
/// functions without problems.
|
/// functions without problems.
|
||||||
LLValue* makeLValue(Loc& loc, DValue* value);
|
LLValue* makeLValue(Loc& loc, DValue* value);
|
||||||
|
|
||||||
void callPostblit(Loc &loc, Expression *exp, LLValue *val);
|
void callPostblit(Loc& loc, Expression *exp, LLValue *val);
|
||||||
|
|
||||||
/// Returns whether the given variable is a DMD-internal "ref variable".
|
/// Returns whether the given variable is a DMD-internal "ref variable".
|
||||||
///
|
///
|
||||||
|
@ -235,7 +235,7 @@ LLConstant* toConstantArray(LLType* ct, LLArrayType* at, T* str, size_t len, boo
|
||||||
///
|
///
|
||||||
/// Necessary to support multiple declarations with the same mangled name, as
|
/// Necessary to support multiple declarations with the same mangled name, as
|
||||||
/// can be the case due to pragma(mangle).
|
/// can be the case due to pragma(mangle).
|
||||||
llvm::GlobalVariable* getOrCreateGlobal(Loc loc, llvm::Module& module,
|
llvm::GlobalVariable* getOrCreateGlobal(Loc& loc, llvm::Module& module,
|
||||||
llvm::Type* type, bool isConstant, llvm::GlobalValue::LinkageTypes linkage,
|
llvm::Type* type, bool isConstant, llvm::GlobalValue::LinkageTypes linkage,
|
||||||
llvm::Constant* init, llvm::StringRef name, bool isThreadLocal = false);
|
llvm::Constant* init, llvm::StringRef name, bool isThreadLocal = false);
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace Logger
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void attention(Loc loc, const char* fmt,...)
|
void attention(Loc& loc, const char* fmt,...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va,fmt);
|
va_start(va,fmt);
|
||||||
|
|
|
@ -302,7 +302,8 @@ static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo)
|
||||||
std::string thismrefname = "_D";
|
std::string thismrefname = "_D";
|
||||||
thismrefname += gIR->dmodule->mangle();
|
thismrefname += gIR->dmodule->mangle();
|
||||||
thismrefname += "11__moduleRefZ";
|
thismrefname += "11__moduleRefZ";
|
||||||
LLGlobalVariable* thismref = getOrCreateGlobal(Loc(), *gIR->module,
|
Loc loc;
|
||||||
|
LLGlobalVariable* thismref = getOrCreateGlobal(loc, *gIR->module,
|
||||||
modulerefTy, false, LLGlobalValue::InternalLinkage, thismrefinit,
|
modulerefTy, false, LLGlobalValue::InternalLinkage, thismrefinit,
|
||||||
thismrefname);
|
thismrefname);
|
||||||
// make sure _Dmodule_ref is declared
|
// make sure _Dmodule_ref is declared
|
||||||
|
@ -352,7 +353,7 @@ static void build_dso_ctor_dtor_body(
|
||||||
llvm::Value* minfoUsedPointer,
|
llvm::Value* minfoUsedPointer,
|
||||||
bool executeWhenInitialized
|
bool executeWhenInitialized
|
||||||
) {
|
) {
|
||||||
llvm::Function* const dsoRegistry = LLVM_D_GetRuntimeFunction(
|
llvm::Function* const dsoRegistry = LLVM_D_GetRuntimeFunction(Loc(),
|
||||||
gIR->module, "_d_dso_registry");
|
gIR->module, "_d_dso_registry");
|
||||||
llvm::Type* const recordPtrTy = dsoRegistry->getFunctionType()->getContainedType(1);
|
llvm::Type* const recordPtrTy = dsoRegistry->getFunctionType()->getContainedType(1);
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ void DtoDefineNakedFunction(FuncDeclaration* fd)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl)
|
void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc& loc, FuncDeclaration* fdecl)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("emitABIReturnAsmStmt(%s)", fdecl->mangleExact());
|
IF_LOG Logger::println("emitABIReturnAsmStmt(%s)", fdecl->mangleExact());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -414,7 +414,7 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl)
|
||||||
|
|
||||||
// sort of kinda related to naked ...
|
// sort of kinda related to naked ...
|
||||||
|
|
||||||
DValue * DtoInlineAsmExpr(Loc loc, FuncDeclaration * fd, Expressions * arguments)
|
DValue * DtoInlineAsmExpr(Loc& loc, FuncDeclaration * fd, Expressions * arguments)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoInlineAsmExpr @ %s", loc.toChars());
|
IF_LOG Logger::println("DtoInlineAsmExpr @ %s", loc.toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
|
@ -32,7 +32,7 @@ static void storeVariable(VarDeclaration *vd, LLValue *dst)
|
||||||
assert(fd && "No parent function for nested variable?");
|
assert(fd && "No parent function for nested variable?");
|
||||||
if (fd->needsClosure() && !vd->isRef() && (ty == Tstruct || ty == Tsarray) && isaPointer(value->getType())) {
|
if (fd->needsClosure() && !vd->isRef() && (ty == Tstruct || ty == Tsarray) && isaPointer(value->getType())) {
|
||||||
// Copy structs and static arrays
|
// Copy structs and static arrays
|
||||||
LLValue *mem = DtoGcMalloc(DtoType(vd->type), ".gc_mem");
|
LLValue *mem = DtoGcMalloc(vd->loc, DtoType(vd->type), ".gc_mem");
|
||||||
DtoAggrCopy(mem, value);
|
DtoAggrCopy(mem, value);
|
||||||
DtoAlignedStore(mem, dst);
|
DtoAlignedStore(mem, dst);
|
||||||
} else
|
} else
|
||||||
|
@ -42,7 +42,7 @@ static void storeVariable(VarDeclaration *vd, LLValue *dst)
|
||||||
|
|
||||||
static void DtoCreateNestedContextType(FuncDeclaration* fd);
|
static void DtoCreateNestedContextType(FuncDeclaration* fd);
|
||||||
|
|
||||||
DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref)
|
DValue* DtoNestedVariable(Loc& loc, Type* astype, VarDeclaration* vd, bool byref)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoNestedVariable for %s @ %s", vd->toChars(), loc.toChars());
|
IF_LOG Logger::println("DtoNestedVariable for %s @ %s", vd->toChars(), loc.toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -165,7 +165,7 @@ DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref)
|
||||||
return new DVarValue(astype, vd, val);
|
return new DVarValue(astype, vd, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DtoResolveNestedContext(Loc loc, AggregateDeclaration *decl, LLValue *value)
|
void DtoResolveNestedContext(Loc& loc, AggregateDeclaration *decl, LLValue *value)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("Resolving nested context");
|
IF_LOG Logger::println("Resolving nested context");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -189,7 +189,7 @@ void DtoResolveNestedContext(Loc loc, AggregateDeclaration *decl, LLValue *value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LLValue* DtoNestedContext(Loc loc, Dsymbol* sym)
|
LLValue* DtoNestedContext(Loc& loc, Dsymbol* sym)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("DtoNestedContext for %s", sym->toPrettyChars());
|
IF_LOG Logger::println("DtoNestedContext for %s", sym->toPrettyChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -416,7 +416,7 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
|
||||||
LLValue* frame = 0;
|
LLValue* frame = 0;
|
||||||
bool needsClosure = fd->needsClosure();
|
bool needsClosure = fd->needsClosure();
|
||||||
if (needsClosure)
|
if (needsClosure)
|
||||||
frame = DtoGcMalloc(frameType, ".frame");
|
frame = DtoGcMalloc(fd->loc, frameType, ".frame");
|
||||||
else
|
else
|
||||||
frame = DtoRawAlloca(frameType, 0, ".frame");
|
frame = DtoRawAlloca(frameType, 0, ".frame");
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,13 @@
|
||||||
void DtoCreateNestedContext(FuncDeclaration* fd);
|
void DtoCreateNestedContext(FuncDeclaration* fd);
|
||||||
|
|
||||||
/// Resolves the nested context for classes and structs with arbitrary nesting.
|
/// Resolves the nested context for classes and structs with arbitrary nesting.
|
||||||
void DtoResolveNestedContext(Loc loc, AggregateDeclaration *decl, LLValue *value);
|
void DtoResolveNestedContext(Loc& loc, AggregateDeclaration *decl, LLValue *value);
|
||||||
|
|
||||||
/// Gets the context value for a call to a nested function or creating a nested
|
/// Gets the context value for a call to a nested function or creating a nested
|
||||||
/// class or struct with arbitrary nesting.
|
/// class or struct with arbitrary nesting.
|
||||||
llvm::Value* DtoNestedContext(Loc loc, Dsymbol* sym);
|
llvm::Value* DtoNestedContext(Loc& loc, Dsymbol* sym);
|
||||||
|
|
||||||
/// Gets the DValue of a nested variable with arbitrary nesting.
|
/// Gets the DValue of a nested variable with arbitrary nesting.
|
||||||
DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref = false);
|
DValue* DtoNestedVariable(Loc& loc, Type* astype, VarDeclaration* vd, bool byref = false);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -126,9 +126,9 @@ void LLVM_D_FreeRuntime()
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name)
|
llvm::Function* LLVM_D_GetRuntimeFunction(const Loc &loc, llvm::Module* target, const char* name)
|
||||||
{
|
{
|
||||||
checkForImplicitGCCall(Loc(), name);
|
checkForImplicitGCCall(loc, name);
|
||||||
|
|
||||||
if (!M) {
|
if (!M) {
|
||||||
LLVM_D_InitRuntime();
|
LLVM_D_InitRuntime();
|
||||||
|
@ -150,14 +150,14 @@ llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* name)
|
llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(Loc& loc, llvm::Module* target, const char* name)
|
||||||
{
|
{
|
||||||
LLGlobalVariable* gv = target->getNamedGlobal(name);
|
LLGlobalVariable* gv = target->getNamedGlobal(name);
|
||||||
if (gv) {
|
if (gv) {
|
||||||
return gv;
|
return gv;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkForImplicitGCCall(Loc(), name);
|
checkForImplicitGCCall(loc, name);
|
||||||
|
|
||||||
if (!M) {
|
if (!M) {
|
||||||
LLVM_D_InitRuntime();
|
LLVM_D_InitRuntime();
|
||||||
|
@ -165,13 +165,13 @@ llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char*
|
||||||
|
|
||||||
LLGlobalVariable* g = M->getNamedGlobal(name);
|
LLGlobalVariable* g = M->getNamedGlobal(name);
|
||||||
if (!g) {
|
if (!g) {
|
||||||
error(Loc(), "Runtime global '%s' was not found", name);
|
error(loc, "Runtime global '%s' was not found", name);
|
||||||
fatal();
|
fatal();
|
||||||
//return NULL;
|
//return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLPointerType* t = g->getType();
|
LLPointerType* t = g->getType();
|
||||||
return getOrCreateGlobal(Loc(), *target, t->getElementType(), g->isConstant(),
|
return getOrCreateGlobal(loc, *target, t->getElementType(), g->isConstant(),
|
||||||
g->getLinkage(), NULL, g->getName());
|
g->getLinkage(), NULL, g->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,16 @@ namespace llvm
|
||||||
class Module;
|
class Module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Loc;
|
||||||
|
|
||||||
// D runtime support helpers
|
// D runtime support helpers
|
||||||
|
|
||||||
bool LLVM_D_InitRuntime();
|
bool LLVM_D_InitRuntime();
|
||||||
void LLVM_D_FreeRuntime();
|
void LLVM_D_FreeRuntime();
|
||||||
|
|
||||||
llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name);
|
llvm::Function* LLVM_D_GetRuntimeFunction(const Loc &loc, llvm::Module* target, const char* name);
|
||||||
|
|
||||||
llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* name);
|
llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(const Loc &loc, llvm::Module* target, const char* name);
|
||||||
|
|
||||||
#define _adEq "_adEq2"
|
#define _adEq "_adEq2"
|
||||||
#define _adCmp "_adCmp2"
|
#define _adCmp "_adCmp2"
|
||||||
|
|
|
@ -85,7 +85,7 @@ static LLValue* call_string_switch_runtime(llvm::Value* table, Expression* e)
|
||||||
llvm_unreachable("not char/wchar/dchar");
|
llvm_unreachable("not char/wchar/dchar");
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname);
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(e->loc, gIR->module, fname);
|
||||||
|
|
||||||
IF_LOG {
|
IF_LOG {
|
||||||
Logger::cout() << *table->getType() << '\n';
|
Logger::cout() << *table->getType() << '\n';
|
||||||
|
@ -866,7 +866,7 @@ public:
|
||||||
|
|
||||||
gIR->DBuilder.EmitFuncEnd(gIR->func()->decl);
|
gIR->DBuilder.EmitFuncEnd(gIR->func()->decl);
|
||||||
|
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_throw_exception");
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(stmt->loc, gIR->module, "_d_throw_exception");
|
||||||
//Logger::cout() << "calling: " << *fn << '\n';
|
//Logger::cout() << "calling: " << *fn << '\n';
|
||||||
LLValue* arg = DtoBitCast(e->getRVal(), fn->getFunctionType()->getParamType(0));
|
LLValue* arg = DtoBitCast(e->getRVal(), fn->getFunctionType()->getParamType(0));
|
||||||
//Logger::cout() << "arg: " << *arg << '\n';
|
//Logger::cout() << "arg: " << *arg << '\n';
|
||||||
|
@ -1550,12 +1550,12 @@ public:
|
||||||
if (stmt->exp)
|
if (stmt->exp)
|
||||||
{
|
{
|
||||||
stmt->llsync = stmt->exp->toElem(irs)->getRVal();
|
stmt->llsync = stmt->exp->toElem(irs)->getRVal();
|
||||||
DtoEnterMonitor(stmt->llsync);
|
DtoEnterMonitor(stmt->loc, stmt->llsync);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stmt->llsync = generate_unique_critical_section();
|
stmt->llsync = generate_unique_critical_section();
|
||||||
DtoEnterCritical(stmt->llsync);
|
DtoEnterCritical(stmt->loc, stmt->llsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
// emit body
|
// emit body
|
||||||
|
@ -1570,9 +1570,9 @@ public:
|
||||||
if (irs->scopereturned())
|
if (irs->scopereturned())
|
||||||
return;
|
return;
|
||||||
else if (stmt->exp)
|
else if (stmt->exp)
|
||||||
DtoLeaveMonitor(stmt->llsync);
|
DtoLeaveMonitor(stmt->loc, stmt->llsync);
|
||||||
else
|
else
|
||||||
DtoLeaveCritical(stmt->llsync);
|
DtoLeaveCritical(stmt->loc, stmt->llsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1581,7 +1581,7 @@ public:
|
||||||
IF_LOG Logger::println("SwitchErrorStatement::toIR(): %s", stmt->loc.toChars());
|
IF_LOG Logger::println("SwitchErrorStatement::toIR(): %s", stmt->loc.toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_switch_error");
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(stmt->loc, gIR->module, "_d_switch_error");
|
||||||
|
|
||||||
LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol();
|
LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol();
|
||||||
LLType *moduleInfoType = DtoType(Module::moduleinfo->type);
|
LLType *moduleInfoType = DtoType(Module::moduleinfo->type);
|
||||||
|
|
|
@ -81,7 +81,7 @@ DValue* DtoVaArg(Loc& loc, Type* type, Expression* valistArg)
|
||||||
// issue a warning for broken va_arg instruction.
|
// issue a warning for broken va_arg instruction.
|
||||||
if (global.params.targetTriple.getArch() != llvm::Triple::x86
|
if (global.params.targetTriple.getArch() != llvm::Triple::x86
|
||||||
&& global.params.targetTriple.getArch() != llvm::Triple::ppc64)
|
&& global.params.targetTriple.getArch() != llvm::Triple::ppc64)
|
||||||
warning(Loc(), "%s: va_arg for C variadic functions is probably broken for anything but x86 and ppc64", loc.toChars());
|
warning(loc, "va_arg for C variadic functions is probably broken for anything but x86 and ppc64");
|
||||||
// done
|
// done
|
||||||
return new DImValue(type, gIR->ir->CreateVAArg(expelem->getLVal(), llt, "tmp"));
|
return new DImValue(type, gIR->ir->CreateVAArg(expelem->getLVal(), llt, "tmp"));
|
||||||
}
|
}
|
||||||
|
|
34
gen/toir.cpp
34
gen/toir.cpp
|
@ -476,7 +476,7 @@ DValue* AssignExp::toElem(IRState* p)
|
||||||
DValue* arr = ale->e1->toElem(p);
|
DValue* arr = ale->e1->toElem(p);
|
||||||
DVarValue arrval(ale->e1->type, arr->getLVal());
|
DVarValue arrval(ale->e1->type, arr->getLVal());
|
||||||
DValue* newlen = e2->toElem(p);
|
DValue* newlen = e2->toElem(p);
|
||||||
DSliceValue* slice = DtoResizeDynArray(arrval.getType(), &arrval, newlen->getRVal());
|
DSliceValue* slice = DtoResizeDynArray(loc, arrval.getType(), &arrval, newlen->getRVal());
|
||||||
DtoAssign(loc, &arrval, slice);
|
DtoAssign(loc, &arrval, slice);
|
||||||
return newlen;
|
return newlen;
|
||||||
}
|
}
|
||||||
|
@ -644,7 +644,7 @@ static void errorOnIllegalArrayOp(Expression* base, Expression* e1, Expression*
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static dinteger_t undoStrideMul(const Loc& loc, Type* t, dinteger_t offset)
|
static dinteger_t undoStrideMul(Loc& loc, Type* t, dinteger_t offset)
|
||||||
{
|
{
|
||||||
assert(t->ty == Tpointer);
|
assert(t->ty == Tpointer);
|
||||||
d_uns64 elemSize = t->nextOf()->size(loc);
|
d_uns64 elemSize = t->nextOf()->size(loc);
|
||||||
|
@ -1624,7 +1624,7 @@ DValue* DotVarExp::toElem(IRState* p)
|
||||||
{
|
{
|
||||||
TypeClass* tc = static_cast<TypeClass*>(e1type);
|
TypeClass* tc = static_cast<TypeClass*>(e1type);
|
||||||
if (tc->sym->isInterfaceDeclaration() && nonFinal && !tc->sym->isCPPinterface())
|
if (tc->sym->isInterfaceDeclaration() && nonFinal && !tc->sym->isCPPinterface())
|
||||||
passedThis = DtoCastInterfaceToObject(l, NULL)->getRVal();
|
passedThis = DtoCastInterfaceToObject(loc, l, NULL)->getRVal();
|
||||||
}
|
}
|
||||||
LLValue* vthis = l->getRVal();
|
LLValue* vthis = l->getRVal();
|
||||||
if (!passedThis) passedThis = vthis;
|
if (!passedThis) passedThis = vthis;
|
||||||
|
@ -2148,7 +2148,7 @@ DValue* NewExp::toElem(IRState* p)
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// default allocator
|
// default allocator
|
||||||
mem = DtoNew(newtype);
|
mem = DtoNew(loc, newtype);
|
||||||
}
|
}
|
||||||
// init
|
// init
|
||||||
TypeStruct* ts = static_cast<TypeStruct*>(ntype);
|
TypeStruct* ts = static_cast<TypeStruct*>(ntype);
|
||||||
|
@ -2178,7 +2178,7 @@ DValue* NewExp::toElem(IRState* p)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// allocate
|
// allocate
|
||||||
LLValue* mem = DtoNew(newtype);
|
LLValue* mem = DtoNew(loc, newtype);
|
||||||
DVarValue tmpvar(newtype, mem);
|
DVarValue tmpvar(newtype, mem);
|
||||||
|
|
||||||
// default initialize
|
// default initialize
|
||||||
|
@ -2207,7 +2207,7 @@ DValue* DeleteExp::toElem(IRState* p)
|
||||||
// simple pointer
|
// simple pointer
|
||||||
if (et->ty == Tpointer)
|
if (et->ty == Tpointer)
|
||||||
{
|
{
|
||||||
DtoDeleteMemory(dval->isLVal() ? dval->getLVal() : makeLValue(loc, dval));
|
DtoDeleteMemory(loc, dval->isLVal() ? dval->getLVal() : makeLValue(loc, dval));
|
||||||
}
|
}
|
||||||
// class
|
// class
|
||||||
else if (et->ty == Tclass)
|
else if (et->ty == Tclass)
|
||||||
|
@ -2217,18 +2217,18 @@ DValue* DeleteExp::toElem(IRState* p)
|
||||||
if (tc->sym->isInterfaceDeclaration())
|
if (tc->sym->isInterfaceDeclaration())
|
||||||
{
|
{
|
||||||
LLValue *val = dval->getLVal();
|
LLValue *val = dval->getLVal();
|
||||||
DtoDeleteInterface(val);
|
DtoDeleteInterface(loc, val);
|
||||||
onstack = true;
|
onstack = true;
|
||||||
}
|
}
|
||||||
else if (DVarValue* vv = dval->isVar()) {
|
else if (DVarValue* vv = dval->isVar()) {
|
||||||
if (vv->var && vv->var->onstack) {
|
if (vv->var && vv->var->onstack) {
|
||||||
DtoFinalizeClass(dval->getRVal());
|
DtoFinalizeClass(loc, dval->getRVal());
|
||||||
onstack = true;
|
onstack = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!onstack) {
|
if (!onstack) {
|
||||||
LLValue* rval = dval->getRVal();
|
LLValue* rval = dval->getRVal();
|
||||||
DtoDeleteClass(rval);
|
DtoDeleteClass(loc, rval);
|
||||||
}
|
}
|
||||||
if (dval->isVar()) {
|
if (dval->isVar()) {
|
||||||
LLValue* lval = dval->getLVal();
|
LLValue* lval = dval->getLVal();
|
||||||
|
@ -2238,7 +2238,7 @@ DValue* DeleteExp::toElem(IRState* p)
|
||||||
// dyn array
|
// dyn array
|
||||||
else if (et->ty == Tarray)
|
else if (et->ty == Tarray)
|
||||||
{
|
{
|
||||||
DtoDeleteArray(dval);
|
DtoDeleteArray(loc, dval);
|
||||||
if (dval->isLVal())
|
if (dval->isLVal())
|
||||||
DtoSetArrayToNull(dval->getLVal());
|
DtoSetArrayToNull(dval->getLVal());
|
||||||
}
|
}
|
||||||
|
@ -2319,7 +2319,7 @@ DValue* AssertExp::toElem(IRState* p)
|
||||||
!(static_cast<TypeClass*>(condty)->sym->isInterfaceDeclaration()))
|
!(static_cast<TypeClass*>(condty)->sym->isInterfaceDeclaration()))
|
||||||
{
|
{
|
||||||
Logger::println("calling class invariant");
|
Logger::println("calling class invariant");
|
||||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module,
|
llvm::Function* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module,
|
||||||
gABI->mangleForLLVM("_D9invariant12_d_invariantFC6ObjectZv", LINKd).c_str());
|
gABI->mangleForLLVM("_D9invariant12_d_invariantFC6ObjectZv", LINKd).c_str());
|
||||||
LLValue* arg = DtoBitCast(cond->getRVal(), fn->getFunctionType()->getParamType(0));
|
LLValue* arg = DtoBitCast(cond->getRVal(), fn->getFunctionType()->getParamType(0));
|
||||||
gIR->CreateCallOrInvoke(fn, arg);
|
gIR->CreateCallOrInvoke(fn, arg);
|
||||||
|
@ -2536,7 +2536,7 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||||
if (cd->isInterfaceDeclaration())
|
if (cd->isInterfaceDeclaration())
|
||||||
{
|
{
|
||||||
Logger::println("context type is interface");
|
Logger::println("context type is interface");
|
||||||
src = DtoCastInterfaceToObject(u, ClassDeclaration::object->type);
|
src = DtoCastInterfaceToObject(loc, u, ClassDeclaration::object->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uval = src->getRVal();
|
uval = src->getRVal();
|
||||||
|
@ -2758,7 +2758,7 @@ DValue* CatExp::toElem(IRState* p)
|
||||||
IF_LOG Logger::print("CatExp::toElem: %s @ %s\n", toChars(), type->toChars());
|
IF_LOG Logger::print("CatExp::toElem: %s @ %s\n", toChars(), type->toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
return DtoCatArrays(type, e1, e2);
|
return DtoCatArrays(loc, type, e1, e2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -2780,14 +2780,14 @@ DValue* CatAssignExp::toElem(IRState* p)
|
||||||
{
|
{
|
||||||
if (elemtype->ty == Tchar)
|
if (elemtype->ty == Tchar)
|
||||||
// append dchar to char[]
|
// append dchar to char[]
|
||||||
DtoAppendDCharToString(l, e2);
|
DtoAppendDCharToString(loc, l, e2);
|
||||||
else /*if (elemtype->ty == Twchar)*/
|
else /*if (elemtype->ty == Twchar)*/
|
||||||
// append dchar to wchar[]
|
// append dchar to wchar[]
|
||||||
DtoAppendDCharToUnicodeString(l, e2);
|
DtoAppendDCharToUnicodeString(loc, l, e2);
|
||||||
}
|
}
|
||||||
else if (e1type->equals(e2type)) {
|
else if (e1type->equals(e2type)) {
|
||||||
// apeend array
|
// apeend array
|
||||||
DSliceValue* slice = DtoCatAssignArray(l,e2);
|
DSliceValue* slice = DtoCatAssignArray(loc, l, e2);
|
||||||
DtoAssign(loc, l, slice);
|
DtoAssign(loc, l, slice);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3397,7 +3397,7 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p)
|
||||||
Type* indexType = static_cast<TypeAArray*>(aatype)->index;
|
Type* indexType = static_cast<TypeAArray*>(aatype)->index;
|
||||||
assert(indexType && vtype);
|
assert(indexType && vtype);
|
||||||
|
|
||||||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_d_assocarrayliteralTX");
|
llvm::Function* func = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_assocarrayliteralTX");
|
||||||
LLFunctionType* funcTy = func->getFunctionType();
|
LLFunctionType* funcTy = func->getFunctionType();
|
||||||
LLValue* aaTypeInfo = DtoBitCast(DtoTypeInfoOf(stripModifiers(aatype)),
|
LLValue* aaTypeInfo = DtoBitCast(DtoTypeInfoOf(stripModifiers(aatype)),
|
||||||
DtoType(Type::typeinfoassociativearray->type));
|
DtoType(Type::typeinfoassociativearray->type));
|
||||||
|
|
|
@ -214,7 +214,7 @@ LLConstant * IrAggr::getVtblInit()
|
||||||
else
|
else
|
||||||
cd->deprecation("use of %s hidden by %s is deprecated", fd->toPrettyChars(), cd->toChars());
|
cd->deprecation("use of %s hidden by %s is deprecated", fd->toPrettyChars(), cd->toChars());
|
||||||
|
|
||||||
c = DtoBitCast(LLVM_D_GetRuntimeFunction(gIR->module, "_d_hidden_func"), c->getType());
|
c = DtoBitCast(LLVM_D_GetRuntimeFunction(Loc(), gIR->module, "_d_hidden_func"), c->getType());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// creates new landing pad
|
// creates new landing pad
|
||||||
static llvm::LandingPadInst *createLandingPadInst()
|
static llvm::LandingPadInst *createLandingPadInst()
|
||||||
{
|
{
|
||||||
llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_personality");
|
llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(Loc(), gIR->module, "_d_eh_personality");
|
||||||
LLType *retType = LLStructType::get(LLType::getInt8PtrTy(gIR->context()),
|
LLType *retType = LLStructType::get(LLType::getInt8PtrTy(gIR->context()),
|
||||||
LLType::getInt32Ty(gIR->context()),
|
LLType::getInt32Ty(gIR->context()),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -98,7 +98,7 @@ void IRLandingPadFinallyStatementInfo::toIR(LLValue *eh_ptr)
|
||||||
llvm::LandingPadInst *collisionLandingPad = createLandingPadInst();
|
llvm::LandingPadInst *collisionLandingPad = createLandingPadInst();
|
||||||
LLValue* collision_eh_ptr = DtoExtractValue(collisionLandingPad, 0);
|
LLValue* collision_eh_ptr = DtoExtractValue(collisionLandingPad, 0);
|
||||||
collisionLandingPad->setCleanup(true);
|
collisionLandingPad->setCleanup(true);
|
||||||
llvm::Function* collision_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_handle_collision");
|
llvm::Function* collision_fn = LLVM_D_GetRuntimeFunction(Loc(), gIR->module, "_d_eh_handle_collision");
|
||||||
gIR->CreateCallOrInvoke2(collision_fn, collision_eh_ptr, eh_ptr);
|
gIR->CreateCallOrInvoke2(collision_fn, collision_eh_ptr, eh_ptr);
|
||||||
gIR->ir->CreateUnreachable();
|
gIR->ir->CreateUnreachable();
|
||||||
gIR->scope() = IRScope(bb, gIR->scopeend());
|
gIR->scope() = IRScope(bb, gIR->scopeend());
|
||||||
|
@ -222,7 +222,7 @@ void IRLandingPad::constructLandingPad(IRLandingPadScope scope)
|
||||||
gIR->func()->gen->landingPad = get();
|
gIR->func()->gen->landingPad = get();
|
||||||
|
|
||||||
// no catch matched and all finallys executed - resume unwind
|
// no catch matched and all finallys executed - resume unwind
|
||||||
llvm::Function* unwind_resume_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_resume_unwind");
|
llvm::Function* unwind_resume_fn = LLVM_D_GetRuntimeFunction(Loc(), gIR->module, "_d_eh_resume_unwind");
|
||||||
gIR->ir->CreateCall(unwind_resume_fn, eh_ptr);
|
gIR->ir->CreateCall(unwind_resume_fn, eh_ptr);
|
||||||
gIR->ir->CreateUnreachable();
|
gIR->ir->CreateUnreachable();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue