DtoTypeInfoOf(): Make Loc param mandatory and move to 1st position

This commit is contained in:
Martin Kinkelin 2020-12-13 15:15:37 +01:00
parent a9aafac862
commit d3574b9835
9 changed files with 35 additions and 35 deletions

View file

@ -25,11 +25,11 @@
#include "ir/irmodule.h"
// returns the keytype typeinfo
static LLConstant *to_keyti(DValue *aa, LLType *targetType) {
static LLConstant *to_keyti(const Loc &loc, DValue *aa, LLType *targetType) {
// keyti param
assert(aa->type->toBasetype()->ty == Taarray);
TypeAArray *aatype = static_cast<TypeAArray *>(aa->type->toBasetype());
LLConstant *ti = DtoTypeInfoOf(aatype->index, /*base=*/false);
LLConstant *ti = DtoTypeInfoOf(loc, aatype->index, /*base=*/false);
return DtoBitCast(ti, targetType);
}
@ -61,13 +61,13 @@ DLValue *DtoAAIndex(const Loc &loc, Type *type, DValue *aa, DValue *key,
LLValue *ret;
if (lvalue) {
LLValue *rawAATI =
DtoTypeInfoOf(aa->type->unSharedOf()->mutableOf(), /*base=*/false, loc);
DtoTypeInfoOf(loc, aa->type->unSharedOf()->mutableOf(), /*base=*/false);
LLValue *castedAATI = DtoBitCast(rawAATI, funcTy->getParamType(1));
LLValue *valsize = DtoConstSize_t(getTypeAllocSize(DtoType(type)));
ret = gIR->CreateCallOrInvoke(func, aaval, castedAATI, valsize, pkey,
"aa.index");
} else {
LLValue *keyti = to_keyti(aa, funcTy->getParamType(1));
LLValue *keyti = to_keyti(loc, aa, funcTy->getParamType(1));
ret = gIR->CreateCallOrInvoke(func, aaval, keyti, pkey, "aa.index");
}
@ -125,7 +125,7 @@ DValue *DtoAAIn(const Loc &loc, Type *type, DValue *aa, DValue *key) {
aaval = DtoBitCast(aaval, funcTy->getParamType(0));
// keyti param
LLValue *keyti = to_keyti(aa, funcTy->getParamType(1));
LLValue *keyti = to_keyti(loc, aa, funcTy->getParamType(1));
// pkey param
LLValue *pkey = makeLValue(loc, key);
@ -169,7 +169,7 @@ DValue *DtoAARemove(const Loc &loc, DValue *aa, DValue *key) {
aaval = DtoBitCast(aaval, funcTy->getParamType(0));
// keyti param
LLValue *keyti = to_keyti(aa, funcTy->getParamType(1));
LLValue *keyti = to_keyti(loc, aa, funcTy->getParamType(1));
// pkey param
LLValue *pkey = makeLValue(loc, key);
@ -192,7 +192,7 @@ LLValue *DtoAAEquals(const Loc &loc, TOK op, DValue *l, DValue *r) {
LLValue *aaval = DtoBitCast(DtoRVal(l), funcTy->getParamType(1));
LLValue *abval = DtoBitCast(DtoRVal(r), funcTy->getParamType(2));
LLValue *aaTypeInfo = DtoTypeInfoOf(t, /*base=*/true, loc);
LLValue *aaTypeInfo = DtoTypeInfoOf(loc, t);
LLValue *res =
gIR->CreateCallOrInvoke(func, aaTypeInfo, aaval, abval, "aaEqRes");

View file

@ -294,17 +294,16 @@ void DtoArrayAssign(const Loc &loc, DValue *lhs, DValue *rhs, int op,
}
} else if (isConstructing) {
LLFunction *fn = getRuntimeFunction(loc, gIR->module, "_d_arrayctor");
gIR->CreateCallOrInvoke(fn, DtoTypeInfoOf(elemType, /*base=*/true, loc),
gIR->CreateCallOrInvoke(fn, DtoTypeInfoOf(loc, elemType),
DtoSlice(rhsPtr, rhsLength),
DtoSlice(lhsPtr, lhsLength));
} else // assigning
{
} else { // assigning
LLValue *tmpSwap = DtoAlloca(elemType, "arrayAssign.tmpSwap");
LLFunction *fn = getRuntimeFunction(
loc, gIR->module,
!canSkipPostblit ? "_d_arrayassign_l" : "_d_arrayassign_r");
gIR->CreateCallOrInvoke(
fn, DtoTypeInfoOf(elemType, /*base=*/true, loc), DtoSlice(rhsPtr, rhsLength),
fn, DtoTypeInfoOf(loc, elemType), DtoSlice(rhsPtr, rhsLength),
DtoSlice(lhsPtr, lhsLength), DtoBitCast(tmpSwap, getVoidPtrType()));
}
} else {
@ -338,7 +337,7 @@ void DtoArrayAssign(const Loc &loc, DValue *lhs, DValue *rhs, int op,
fn, lhsPtr, DtoBitCast(makeLValue(loc, rhs), getVoidPtrType()),
gIR->ir->CreateTruncOrBitCast(lhsLength,
LLType::getInt32Ty(gIR->context())),
DtoTypeInfoOf(stripModifiers(t2), /*base=*/true, loc));
DtoTypeInfoOf(loc, stripModifiers(t2)));
}
}
}
@ -694,7 +693,7 @@ DSliceValue *DtoNewDynArray(const Loc &loc, Type *arrayType, DValue *dim,
LLFunction *fn = getRuntimeFunction(loc, gIR->module, fnname);
// typeinfo arg
LLValue *arrayTypeInfo = DtoTypeInfoOf(arrayType, /*base=*/true, loc);
LLValue *arrayTypeInfo = DtoTypeInfoOf(loc, arrayType);
// dim arg
assert(DtoType(dim->type) == DtoSize_t());
@ -728,7 +727,7 @@ DSliceValue *DtoNewMulDimDynArray(const Loc &loc, Type *arrayType,
LLFunction *fn = getRuntimeFunction(loc, gIR->module, fnname);
// typeinfo arg
LLValue *arrayTypeInfo = DtoTypeInfoOf(arrayType, /*base=*/true, loc);
LLValue *arrayTypeInfo = DtoTypeInfoOf(loc, arrayType);
// Check if constant
bool allDimsConst = true;
@ -799,7 +798,7 @@ DSliceValue *DtoResizeDynArray(const Loc &loc, Type *arrayType, DValue *array,
: "_d_arraysetlengthiT");
LLValue *newArray = gIR->CreateCallOrInvoke(
fn, DtoTypeInfoOf(arrayType, /*base=*/true, loc), newdim,
fn, DtoTypeInfoOf(loc, arrayType), newdim,
DtoBitCast(DtoLVal(array), fn->getFunctionType()->getParamType(2)),
".gc_mem");
@ -823,7 +822,7 @@ void DtoCatAssignElement(const Loc &loc, DValue *array, Expression *exp) {
// potentially moved to a new block).
LLFunction *fn = getRuntimeFunction(loc, gIR->module, "_d_arrayappendcTX");
gIR->CreateCallOrInvoke(
fn, DtoTypeInfoOf(arrayType, /*base=*/true, loc),
fn, DtoTypeInfoOf(loc, arrayType),
DtoBitCast(DtoLVal(array), fn->getFunctionType()->getParamType(1)),
DtoConstSize_t(1), ".appendedArray");
@ -848,7 +847,7 @@ DSliceValue *DtoCatAssignArray(const Loc &loc, DValue *arr, Expression *exp) {
LLFunction *fn = getRuntimeFunction(loc, gIR->module, "_d_arrayappendT");
// Call _d_arrayappendT(TypeInfo ti, byte[] *px, byte[] y)
LLValue *newArray = gIR->CreateCallOrInvoke(
fn, DtoTypeInfoOf(arrayType, /*base=*/true, loc),
fn, DtoTypeInfoOf(loc, arrayType),
DtoBitCast(DtoLVal(arr), fn->getFunctionType()->getParamType(1)),
DtoAggrPaint(DtoSlice(exp), fn->getFunctionType()->getParamType(2)),
".appendedArray");
@ -902,14 +901,14 @@ DSliceValue *DtoCatArrays(const Loc &loc, Type *arrayType, Expression *exp1,
LLType::getInt8Ty(gIR->context()))))));
// TypeInfo ti
args.push_back(DtoTypeInfoOf(arrayType, /*base=*/true, loc));
args.push_back(DtoTypeInfoOf(loc, arrayType));
// byte[][] arrs
args.push_back(val);
} else {
fn = getRuntimeFunction(loc, gIR->module, "_d_arraycatT");
// TypeInfo ti
args.push_back(DtoTypeInfoOf(arrayType, /*base=*/true, loc));
args.push_back(DtoTypeInfoOf(loc, arrayType));
// byte[] x
LLValue *val = DtoLoad(DtoSlicePtr(exp1));
val = DtoAggrPaint(val, fn->getFunctionType()->getParamType(1));
@ -987,7 +986,7 @@ LLValue *DtoArrayEqCmp_impl(const Loc &loc, const char *func, DValue *l,
// pass array typeinfo ?
if (useti) {
LLValue *tival = DtoTypeInfoOf(l->type, /*base=*/true, loc);
LLValue *tival = DtoTypeInfoOf(loc, l->type);
args.push_back(DtoBitCast(tival, fn->getFunctionType()->getParamType(2)));
}

View file

@ -82,7 +82,7 @@ LLValue *DtoNew(const Loc &loc, Type *newtype) {
// get runtime function
llvm::Function *fn = getRuntimeFunction(loc, gIR->module, "_d_allocmemoryT");
// get type info
LLConstant *ti = DtoTypeInfoOf(newtype, /*base=*/true, loc);
LLConstant *ti = DtoTypeInfoOf(loc, newtype);
assert(isaPointer(ti));
// call runtime allocator
LLValue *mem = gIR->CreateCallOrInvoke(fn, ti, ".gc_mem");
@ -94,7 +94,7 @@ LLValue *DtoNewStruct(const Loc &loc, TypeStruct *newtype) {
llvm::Function *fn = getRuntimeFunction(
loc, gIR->module,
newtype->isZeroInit(newtype->sym->loc) ? "_d_newitemT" : "_d_newitemiT");
LLConstant *ti = DtoTypeInfoOf(newtype, /*base=*/true, loc);
LLConstant *ti = DtoTypeInfoOf(loc, newtype);
LLValue *mem = gIR->CreateCallOrInvoke(fn, ti, ".gc_struct");
return DtoBitCast(mem, DtoPtrToType(newtype), ".gc_struct");
}
@ -111,7 +111,7 @@ void DtoDeleteStruct(const Loc &loc, DValue *ptr) {
LLValue *lval = (ptr->isLVal() ? DtoLVal(ptr) : makeLValue(loc, ptr));
gIR->CreateCallOrInvoke(
fn, DtoBitCast(lval, fn->getFunctionType()->getParamType(0)),
DtoBitCast(DtoTypeInfoOf(ptr->type->nextOf(), /*base=*/true, loc),
DtoBitCast(DtoTypeInfoOf(loc, ptr->type->nextOf()),
fn->getFunctionType()->getParamType(1)));
}
@ -137,8 +137,8 @@ void DtoDeleteArray(const Loc &loc, DValue *arr) {
Type *elementType = arr->type->nextOf();
bool hasDtor = (elementType->toBasetype()->ty == Tstruct &&
elementType->needsDestruction());
LLValue *typeInfo = (!hasDtor ? getNullPtr(fty->getParamType(1))
: DtoTypeInfoOf(elementType, /*base=*/true, loc));
LLValue *typeInfo = !hasDtor ? getNullPtr(fty->getParamType(1))
: DtoTypeInfoOf(loc, elementType);
LLValue *lval = (arr->isLVal() ? DtoLVal(arr) : makeLValue(loc, arr));
gIR->CreateCallOrInvoke(fn, DtoBitCast(lval, fty->getParamType(0)),
@ -1192,7 +1192,7 @@ LLConstant *DtoConstExpInit(const Loc &loc, Type *targetType, Expression *exp) {
////////////////////////////////////////////////////////////////////////////////
LLConstant *DtoTypeInfoOf(Type *type, bool base, const Loc &loc) {
LLConstant *DtoTypeInfoOf(const Loc &loc, Type *type, bool base) {
IF_LOG Logger::println("DtoTypeInfoOf(type = '%s', base='%d')",
type->toChars(), base);
LOG_SCOPE

View file

@ -126,7 +126,7 @@ LLConstant *DtoConstInitializer(const Loc &loc, Type *type,
LLConstant *DtoConstExpInit(const Loc &loc, Type *targetType, Expression *exp);
// getting typeinfo of type, base=true casts to object.TypeInfo
LLConstant *DtoTypeInfoOf(Type *type, bool base = true, const Loc &loc = Loc());
LLConstant *DtoTypeInfoOf(const Loc &loc, Type *type, bool base = true);
// target stuff
void findDefaultTarget();

View file

@ -62,7 +62,7 @@ void RTTIBuilder::push_null(Type *T) { push(getNullValue(DtoType(T))); }
void RTTIBuilder::push_null_vp() { push(getNullValue(getVoidPtrType())); }
void RTTIBuilder::push_typeinfo(Type *t) { push(DtoTypeInfoOf(t)); }
void RTTIBuilder::push_typeinfo(Type *t) { push(DtoTypeInfoOf(Loc(), t)); }
void RTTIBuilder::push_string(const char *str) { push(DtoConstString(str)); }

View file

@ -250,7 +250,8 @@ static LLValue *getTypeinfoArrayArgumentForDVarArg(Expressions *argexps,
std::vector<LLConstant *> vtypeinfos;
vtypeinfos.reserve(numVariadicArgs);
for (size_t i = begin; i < numArgExps; i++) {
vtypeinfos.push_back(DtoTypeInfoOf((*argexps)[i]->type, /*base=*/true, (*argexps)[i]->loc));
Expression *argExp = (*argexps)[i];
vtypeinfos.push_back(DtoTypeInfoOf(argExp->loc, argExp->type));
}
// apply initializer

View file

@ -82,7 +82,7 @@ public:
}
if (TypeInfoDeclaration *ti = e->var->isTypeInfoDeclaration()) {
result = DtoTypeInfoOf(ti->tinfo, false, e->loc);
result = DtoTypeInfoOf(e->loc, ti->tinfo, /*base=*/false);
result = DtoBitCast(result, DtoType(e->type));
return;
}
@ -685,7 +685,7 @@ public:
return;
}
result = DtoTypeInfoOf(t, /*base=*/false, e->loc);
result = DtoTypeInfoOf(e->loc, t, /*base=*/false);
result = DtoBitCast(result, DtoType(e->type));
}

View file

@ -2402,8 +2402,8 @@ public:
llvm::Function *func =
getRuntimeFunction(e->loc, gIR->module, "_d_assocarrayliteralTX");
LLFunctionType *funcTy = func->getFunctionType();
LLValue *aaTypeInfo =
DtoBitCast(DtoTypeInfoOf(stripModifiers(aatype), /*base=*/false, e->loc),
LLValue *aaTypeInfo = DtoBitCast(
DtoTypeInfoOf(e->loc, stripModifiers(aatype), /*base=*/false),
DtoType(getAssociativeArrayTypeInfoType()));
LLConstant *idxs[2] = {DtoConstUint(0), DtoConstUint(0)};

View file

@ -314,7 +314,7 @@ public:
LLType *tiTy = DtoType(getTypeInfoType());
for (auto arg : *tu->arguments) {
arrInits.push_back(DtoTypeInfoOf(arg->type));
arrInits.push_back(DtoTypeInfoOf(decl->loc, arg->type));
}
// build array