mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 15:40:55 +03:00
Refactor common i1ToI8(voidToI8(DtoType(...)))
code occurrences
This commit is contained in:
parent
5617319770
commit
b13565c17e
14 changed files with 56 additions and 83 deletions
|
@ -75,7 +75,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
|
|||
}
|
||||
|
||||
// cast return value
|
||||
LLType* targettype = getPtrToType(i1ToI8(DtoType(type)));
|
||||
LLType* targettype = DtoPtrToType(type);
|
||||
if (ret->getType() != targettype)
|
||||
ret = DtoBitCast(ret, targettype);
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ struct ExplicitByvalRewrite : ABIRewrite
|
|||
|
||||
LLType* type(Type* dty, LLType* t)
|
||||
{
|
||||
return getPtrToType(DtoType(dty));
|
||||
return DtoPtrToType(dty);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ struct ImplicitByvalRewrite : ABIRewrite {
|
|||
}
|
||||
|
||||
LLType* type(Type* dty, LLType* t) {
|
||||
return getPtrToType(DtoType(dty));
|
||||
return DtoPtrToType(dty);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ static LLValue *DtoSlice(LLValue *ptr, LLValue *length, LLType *elemType = NULL)
|
|||
{
|
||||
if (elemType == NULL)
|
||||
elemType = ptr->getType()->getContainedType(0);
|
||||
elemType = voidToI8(elemType);
|
||||
elemType = i1ToI8(voidToI8(elemType));
|
||||
|
||||
LLStructType *type = DtoArrayType(elemType);
|
||||
LLValue *array = DtoRawAlloca(type, 0, ".array");
|
||||
|
@ -80,9 +80,7 @@ static LLValue *DtoSlicePtr(DValue *dval)
|
|||
LLStructType* DtoArrayType(Type* arrayTy)
|
||||
{
|
||||
assert(arrayTy->nextOf());
|
||||
LLType* elemty = i1ToI8(voidToI8(DtoType(arrayTy->nextOf())));
|
||||
|
||||
llvm::Type *elems[] = { DtoSize_t(), getPtrToType(elemty) };
|
||||
llvm::Type* elems[] = { DtoSize_t(), DtoPtrToType(arrayTy->nextOf()) };
|
||||
return llvm::StructType::get(gIR->context(), elems, false);
|
||||
}
|
||||
|
||||
|
@ -101,8 +99,7 @@ LLArrayType* DtoStaticArrayType(Type* t)
|
|||
TypeSArray* tsa = static_cast<TypeSArray*>(t);
|
||||
Type* tnext = tsa->nextOf();
|
||||
|
||||
LLType* elemty = i1ToI8(voidToI8(DtoType(tnext)));
|
||||
return LLArrayType::get(elemty, tsa->dim->toUInteger());
|
||||
return LLArrayType::get(DtoMemType(tnext), tsa->dim->toUInteger());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -277,7 +274,7 @@ void DtoArrayAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPost
|
|||
if (!needsDestruction && !needsPostblit)
|
||||
{
|
||||
// fast version
|
||||
LLValue* elemSize = DtoConstSize_t(getTypePaddedSize(voidToI8(DtoType(elemType))));
|
||||
LLValue* elemSize = DtoConstSize_t(getTypePaddedSize(DtoMemType(elemType)));
|
||||
LLValue* lhsSize = gIR->ir->CreateMul(elemSize, lhsLength);
|
||||
|
||||
if (rhs->isNull())
|
||||
|
@ -328,7 +325,7 @@ void DtoArrayAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPost
|
|||
// fast version
|
||||
LLValue* elemSize = DtoConstSize_t(getTypePaddedSize(realLhsPtr->getType()->getContainedType(0)));
|
||||
LLValue* lhsSize = gIR->ir->CreateMul(elemSize, lhsLength);
|
||||
LLType* rhsType = i1ToI8(voidToI8(DtoType(t2)));
|
||||
LLType* rhsType = DtoMemType(t2);
|
||||
LLValue* rhsSize = DtoConstSize_t(getTypePaddedSize(rhsType));
|
||||
LLValue* actualPtr = DtoBitCast(lhsPtr, rhsType->getPointerTo());
|
||||
LLValue* actualLength = gIR->ir->CreateExactUDiv(lhsSize, rhsSize);
|
||||
|
@ -397,7 +394,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit, Type* targetType
|
|||
elemty = static_cast<TypeVector *>(arrty)->elementType();
|
||||
else
|
||||
elemty = arrty->nextOf();
|
||||
LLType* llelemty = i1ToI8(voidToI8(DtoType(elemty)));
|
||||
LLType* llelemty = DtoMemType(elemty);
|
||||
|
||||
// true if array elements differ in type, can happen with array of unions
|
||||
bool mismatch = false;
|
||||
|
@ -547,7 +544,7 @@ llvm::Constant* arrayLiteralToConst(IRState* p, ArrayLiteralExp* ale)
|
|||
if (!elementType)
|
||||
{
|
||||
assert(ale->elements->dim == 0);
|
||||
elementType = i1ToI8(voidToI8(DtoType(ale->type->toBasetype()->nextOf())));
|
||||
elementType = DtoMemType(ale->type->toBasetype()->nextOf());
|
||||
return llvm::ConstantArray::get(LLArrayType::get(elementType, 0), vals);
|
||||
}
|
||||
|
||||
|
@ -1067,7 +1064,7 @@ LLValue* DtoArrayPtr(DValue* v)
|
|||
if (DSliceValue* s = v->isSlice())
|
||||
return s->ptr;
|
||||
else if (v->isNull())
|
||||
return getNullPtr(getPtrToType(i1ToI8(DtoType(t->nextOf()))));
|
||||
return getNullPtr(DtoPtrToType(t->nextOf()));
|
||||
else if (v->isLVal())
|
||||
return DtoLoad(DtoGEPi(v->getLVal(), 0,1), ".ptr");
|
||||
return gIR->ir->CreateExtractValue(v->getRVal(), 1, ".ptr");
|
||||
|
@ -1112,7 +1109,7 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to)
|
|||
IF_LOG Logger::cout() << "to array" << '\n';
|
||||
|
||||
LLType* ptrty = DtoArrayType(totype)->getContainedType(1);
|
||||
LLType* ety = voidToI8(DtoType(fromtype->nextOf()));
|
||||
LLType* ety = DtoMemType(fromtype->nextOf());
|
||||
|
||||
if (fromtype->ty == Tsarray) {
|
||||
LLValue* uval = u->getRVal();
|
||||
|
|
|
@ -72,7 +72,7 @@ LLValue* DtoNew(Loc& loc, Type* newtype)
|
|||
// call runtime allocator
|
||||
LLValue* mem = gIR->CreateCallOrInvoke(fn, ti, ".gc_mem").getInstruction();
|
||||
// cast
|
||||
return DtoBitCast(mem, getPtrToType(i1ToI8(DtoType(newtype))), ".gc_mem");
|
||||
return DtoBitCast(mem, DtoPtrToType(newtype), ".gc_mem");
|
||||
}
|
||||
|
||||
LLValue* DtoNewStruct(Loc& loc, TypeStruct* newtype)
|
||||
|
@ -81,7 +81,7 @@ LLValue* DtoNewStruct(Loc& loc, TypeStruct* newtype)
|
|||
newtype->isZeroInit(newtype->sym->loc) ? "_d_newitemT" : "_d_newitemiT");
|
||||
LLConstant* ti = DtoTypeInfoOf(newtype);
|
||||
LLValue* mem = gIR->CreateCallOrInvoke(fn, ti, ".gc_struct").getInstruction();
|
||||
return DtoBitCast(mem, getPtrToType(i1ToI8(DtoType(newtype))), ".gc_struct");
|
||||
return DtoBitCast(mem, DtoPtrToType(newtype), ".gc_struct");
|
||||
}
|
||||
|
||||
void DtoDeleteMemory(Loc& loc, DValue* ptr)
|
||||
|
@ -141,8 +141,7 @@ void DtoDeleteArray(Loc& loc, DValue* arr)
|
|||
|
||||
llvm::AllocaInst* DtoAlloca(Type* type, const char* name)
|
||||
{
|
||||
LLType* lltype = i1ToI8(DtoType(type));
|
||||
return DtoRawAlloca(lltype, type->alignsize(), name);
|
||||
return DtoRawAlloca(DtoMemType(type), type->alignsize(), name);
|
||||
}
|
||||
|
||||
llvm::AllocaInst* DtoArrayAlloca(Type* type, unsigned arraysize, const char* name)
|
||||
|
@ -201,8 +200,8 @@ LLValue* DtoAllocaDump(LLValue* val, Type* asType, const char* name)
|
|||
|
||||
LLValue* DtoAllocaDump(LLValue* val, LLType* asType, int alignment, const char* name)
|
||||
{
|
||||
LLType* valType = i1ToI8(val->getType());
|
||||
asType = i1ToI8(asType);
|
||||
LLType* valType = i1ToI8(voidToI8(val->getType()));
|
||||
asType = i1ToI8(voidToI8(asType));
|
||||
LLType* allocaType = (
|
||||
getTypeStoreSize(valType) <= getTypeAllocSize(asType) ? asType : valType);
|
||||
LLValue* mem = DtoRawAlloca(allocaType, alignment, name);
|
||||
|
@ -391,7 +390,7 @@ DValue* DtoNullValue(Type* type, Loc loc)
|
|||
else if (basety == Tarray)
|
||||
{
|
||||
LLValue* len = DtoConstSize_t(0);
|
||||
LLValue* ptr = getNullPtr(getPtrToType(DtoType(basetype->nextOf())));
|
||||
LLValue* ptr = getNullPtr(DtoPtrToType(basetype->nextOf()));
|
||||
return new DSliceValue(type, len, ptr);
|
||||
}
|
||||
else
|
||||
|
@ -727,7 +726,7 @@ DValue* DtoPaintType(Loc& loc, DValue* val, Type* to)
|
|||
{
|
||||
LLValue* ptr = val->getLVal();
|
||||
assert(isaPointer(ptr));
|
||||
ptr = DtoBitCast(ptr, getPtrToType(DtoType(dgty)));
|
||||
ptr = DtoBitCast(ptr, DtoPtrToType(dgty));
|
||||
IF_LOG Logger::cout() << "dg ptr: " << *ptr << '\n';
|
||||
return new DVarValue(to, ptr);
|
||||
}
|
||||
|
@ -866,7 +865,7 @@ void DtoResolveVariable(VarDeclaration* vd)
|
|||
}
|
||||
|
||||
llvm::GlobalVariable* gvar = getOrCreateGlobal(vd->loc, gIR->module,
|
||||
i1ToI8(DtoType(vd->type)), isLLConst, linkage, 0, llName,
|
||||
DtoMemType(vd->type), isLLConst, linkage, 0, llName,
|
||||
vd->isThreadlocal());
|
||||
getIrGlobal(vd)->value = gvar;
|
||||
|
||||
|
@ -1183,7 +1182,7 @@ LLConstant* DtoConstInitializer(Loc& loc, Type* type, Initializer* init)
|
|||
else if (init->isVoidInitializer())
|
||||
{
|
||||
Logger::println("const void initializer");
|
||||
LLType* ty = voidToI8(DtoType(type));
|
||||
LLType* ty = DtoMemType(type);
|
||||
_init = LLConstant::getNullValue(ty);
|
||||
}
|
||||
else
|
||||
|
@ -1225,7 +1224,7 @@ LLConstant* DtoConstExpInit(Loc& loc, Type* targetType, Expression* exp)
|
|||
}
|
||||
|
||||
llvm::Type* llType = val->getType();
|
||||
llvm::Type* targetLLType = i1ToI8(DtoType(targetBase));
|
||||
llvm::Type* targetLLType = DtoMemType(targetBase);
|
||||
if (llType == targetLLType)
|
||||
{
|
||||
Logger::println("Matching LLVM types, ignoring frontend glitch.");
|
||||
|
@ -1653,7 +1652,7 @@ DValue* DtoSymbolAddress(Loc& loc, Type* type, Declaration* decl)
|
|||
|
||||
if (isGlobal)
|
||||
{
|
||||
llvm::Type* expectedType = llvm::PointerType::getUnqual(i1ToI8(DtoType(type)));
|
||||
llvm::Type* expectedType = llvm::PointerType::getUnqual(DtoMemType(type));
|
||||
// The type of globals is determined by their initializer, so
|
||||
// we might need to cast. Make sure that the type sizes fit -
|
||||
// '==' instead of '<=' should probably work as well.
|
||||
|
@ -1841,7 +1840,7 @@ LLValue* DtoIndexAggregate(LLValue* src, AggregateDeclaration* ad, VarDeclaratio
|
|||
}
|
||||
|
||||
// Cast the (possibly void*) pointer to the canonical variable type.
|
||||
val = DtoBitCast(val, getPtrToType(i1ToI8(DtoType(vd->type))));
|
||||
val = DtoBitCast(val, DtoPtrToType(vd->type));
|
||||
|
||||
IF_LOG Logger::cout() << "Value: " << *val << '\n';
|
||||
return val;
|
||||
|
|
|
@ -424,8 +424,7 @@ static void build_dso_ctor_dtor_body(
|
|||
static void build_module_ref(std::string moduleMangle, llvm::Constant* thisModuleInfo)
|
||||
{
|
||||
// Build the ModuleInfo reference and bracketing symbols.
|
||||
llvm::Type* const moduleInfoPtrTy =
|
||||
getPtrToType(DtoType(Module::moduleinfo->type));
|
||||
llvm::Type* const moduleInfoPtrTy = DtoPtrToType(Module::moduleinfo->type);
|
||||
|
||||
std::string thismrefname = "_D";
|
||||
thismrefname += moduleMangle;
|
||||
|
@ -445,8 +444,7 @@ static void build_module_ref(std::string moduleMangle, llvm::Constant* thisModul
|
|||
static void build_dso_registry_calls(std::string moduleMangle, llvm::Constant* thisModuleInfo)
|
||||
{
|
||||
// Build the ModuleInfo reference and bracketing symbols.
|
||||
llvm::Type* const moduleInfoPtrTy =
|
||||
getPtrToType(DtoType(Module::moduleinfo->type));
|
||||
llvm::Type* const moduleInfoPtrTy = DtoPtrToType(Module::moduleinfo->type);
|
||||
|
||||
// Order is important here: We must create the symbols in the
|
||||
// bracketing sections right before/after the ModuleInfo reference
|
||||
|
@ -789,8 +787,7 @@ static void genModuleInfo(Module *m, bool emitFullModuleInfo)
|
|||
RTTIBuilder b(Module::moduleinfo);
|
||||
|
||||
// some types
|
||||
llvm::Type* const moduleInfoPtrTy =
|
||||
getPtrToType(DtoType(Module::moduleinfo->type));
|
||||
llvm::Type* const moduleInfoPtrTy = DtoPtrToType(Module::moduleinfo->type);
|
||||
LLType* classinfoTy = Type::typeinfoclass->type->ctype->getLLType();
|
||||
|
||||
// importedModules[]
|
||||
|
|
|
@ -64,7 +64,7 @@ DValue* DtoNestedVariable(Loc& loc, Type* astype, VarDeclaration* vd, bool byref
|
|||
while (fd != vdparent) {
|
||||
if (fd->isStatic()) {
|
||||
error(loc, "function %s cannot access frame of function %s", irfunc->decl->toPrettyChars(), vdparent->toPrettyChars());
|
||||
return new DVarValue(astype, vd, llvm::UndefValue::get(getPtrToType(DtoType(astype))));
|
||||
return new DVarValue(astype, vd, llvm::UndefValue::get(DtoPtrToType(astype)));
|
||||
}
|
||||
fd = getParentFunc(fd, false);
|
||||
assert(fd);
|
||||
|
@ -379,14 +379,14 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
|||
if (lazy)
|
||||
types.push_back(irparam->value->getType()->getContainedType(0));
|
||||
else
|
||||
types.push_back(i1ToI8(DtoType(vd->type)));
|
||||
types.push_back(DtoMemType(vd->type));
|
||||
} else {
|
||||
types.push_back(irparam->value->getType());
|
||||
}
|
||||
} else if (isSpecialRefVar(vd)) {
|
||||
types.push_back(DtoType(vd->type->pointerTo()));
|
||||
} else {
|
||||
types.push_back(i1ToI8(DtoType(vd->type)));
|
||||
types.push_back(DtoMemType(vd->type));
|
||||
}
|
||||
IF_LOG Logger::cout() << "Nested var '" << vd->toChars()
|
||||
<< "' of type " << *types.back() << "\n";
|
||||
|
|
|
@ -175,7 +175,7 @@ public:
|
|||
bool nullterm = (t->ty != Tsarray);
|
||||
size_t endlen = nullterm ? e->len+1 : e->len;
|
||||
|
||||
LLType* ct = voidToI8(DtoType(cty));
|
||||
LLType* ct = DtoMemType(cty);
|
||||
LLArrayType* at = LLArrayType::get(ct,endlen);
|
||||
|
||||
llvm::StringMap<llvm::GlobalVariable*>* stringLiteralCache = 0;
|
||||
|
@ -571,7 +571,7 @@ public:
|
|||
Type* elemt = bt->nextOf();
|
||||
|
||||
// build llvm array type
|
||||
LLArrayType* arrtype = LLArrayType::get(i1ToI8(voidToI8(DtoType(elemt))), e->elements->dim);
|
||||
LLArrayType* arrtype = LLArrayType::get(DtoMemType(elemt), e->elements->dim);
|
||||
|
||||
// dynamic arrays can occur here as well ...
|
||||
bool dyn = (bt->ty != Tsarray);
|
||||
|
|
12
gen/toir.cpp
12
gen/toir.cpp
|
@ -430,7 +430,7 @@ public:
|
|||
Type* dtype = e->type->toBasetype();
|
||||
Type* cty = dtype->nextOf()->toBasetype();
|
||||
|
||||
LLType* ct = voidToI8(DtoType(cty));
|
||||
LLType* ct = DtoMemType(cty);
|
||||
LLArrayType* at = LLArrayType::get(ct, e->len+1);
|
||||
|
||||
llvm::StringMap<llvm::GlobalVariable*>* stringLiteralCache = 0;
|
||||
|
@ -992,7 +992,7 @@ public:
|
|||
|
||||
// handle cast to void (usually created by frontend to avoid "has no effect" error)
|
||||
if (e->to == Type::tvoid) {
|
||||
result = new DImValue(Type::tvoid, llvm::UndefValue::get(voidToI8(DtoType(Type::tvoid))));
|
||||
result = new DImValue(Type::tvoid, llvm::UndefValue::get(DtoMemType(Type::tvoid)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2370,7 +2370,7 @@ public:
|
|||
if (retPtr)
|
||||
result = new DVarValue(e->type, DtoLoad(retPtr));
|
||||
else
|
||||
result = new DConstValue(e->type, getNullValue(voidToI8(DtoType(dtype))));
|
||||
result = new DConstValue(e->type, getNullValue(DtoMemType(dtype)));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2551,7 +2551,7 @@ public:
|
|||
IF_LOG Logger::cout() << (dyn?"dynamic":"static") << " array literal with length " << len << " of D type: '" << arrayType->toChars() << "' has llvm type: '" << *llType << "'\n";
|
||||
|
||||
// llvm storage type
|
||||
LLType* llElemType = i1ToI8(voidToI8(DtoType(elemType)));
|
||||
LLType* llElemType = DtoMemType(elemType);
|
||||
LLType* llStoType = LLArrayType::get(llElemType, len);
|
||||
IF_LOG Logger::cout() << "llvm storage type: '" << *llStoType << "'\n";
|
||||
|
||||
|
@ -2821,7 +2821,7 @@ public:
|
|||
// (&a.foo).funcptr is a case where toElem(e1) is genuinely not an l-value.
|
||||
LLValue* val = makeLValue(exp->loc, toElem(exp->e1));
|
||||
LLValue* v = DtoGEPi(val, 0, index);
|
||||
return new DVarValue(exp->type, DtoBitCast(v, getPtrToType(DtoType(exp->type))));
|
||||
return new DVarValue(exp->type, DtoBitCast(v, DtoPtrToType(exp->type)));
|
||||
}
|
||||
|
||||
void visit(DelegatePtrExp *e)
|
||||
|
@ -2885,7 +2885,7 @@ public:
|
|||
types.reserve(e->exps->dim);
|
||||
for (size_t i = 0; i < e->exps->dim; i++)
|
||||
{
|
||||
types.push_back(i1ToI8(voidToI8(DtoType((*e->exps)[i]->type))));
|
||||
types.push_back(DtoMemType((*e->exps)[i]->type));
|
||||
}
|
||||
LLValue *val = DtoRawAlloca(LLStructType::get(gIR->context(), types), 0, ".tuple");
|
||||
for (size_t i = 0; i < e->exps->dim; i++)
|
||||
|
|
|
@ -202,44 +202,21 @@ LLType* DtoType(Type* t)
|
|||
return IrTypeVector::get(t)->getLLType();
|
||||
}
|
||||
|
||||
/*
|
||||
Not needed atm as VarDecls for tuples are rewritten as a string of
|
||||
VarDecls for the fields (u -> _u_field_0, ...)
|
||||
|
||||
case Ttuple:
|
||||
{
|
||||
TypeTuple* ttupl = static_cast<TypeTuple*>(t);
|
||||
return DtoStructTypeFromArguments(ttupl->arguments);
|
||||
}
|
||||
*/
|
||||
|
||||
default:
|
||||
llvm_unreachable("Unknown class of D Type!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
LLType* DtoStructTypeFromArguments(Arguments* arguments)
|
||||
LLType* DtoMemType(Type* t)
|
||||
{
|
||||
if (!arguments)
|
||||
return LLType::getVoidTy(gIR->context());
|
||||
return i1ToI8(voidToI8(DtoType(t)));
|
||||
}
|
||||
|
||||
std::vector<LLType*> types;
|
||||
for (size_t i = 0; i < arguments->dim; i++)
|
||||
LLPointerType* DtoPtrToType(Type* t)
|
||||
{
|
||||
Argument *arg = (*arguments)[i];
|
||||
assert(arg && arg->type);
|
||||
|
||||
types.push_back(DtoType(arg->type));
|
||||
return DtoMemType(t)->getPointerTo();
|
||||
}
|
||||
return LLStructType::get(types);
|
||||
}
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLType* voidToI8(LLType* t)
|
||||
{
|
||||
|
@ -248,8 +225,6 @@ LLType* voidToI8(LLType* t)
|
|||
return t;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LLType* i1ToI8(LLType* t)
|
||||
{
|
||||
if (t == LLType::getInt1Ty(gIR->context()))
|
||||
|
|
|
@ -32,6 +32,11 @@
|
|||
* DtoTypeFunction(FuncDeclaration*) is to be used instead.
|
||||
*/
|
||||
LLType* DtoType(Type* t);
|
||||
// Uses DtoType(), but promotes i1 and void to i8.
|
||||
LLType* DtoMemType(Type* t);
|
||||
// Returns a pointer to the type returned by DtoMemType(t).
|
||||
LLPointerType* DtoPtrToType(Type* t);
|
||||
|
||||
LLType* voidToI8(LLType* t);
|
||||
LLType* i1ToI8(LLType* t);
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ LLConstant* get_default_initializer(VarDeclaration* vd, Initializer* init)
|
|||
{
|
||||
// We need to be able to handle void[0] struct members even if void has
|
||||
// no default initializer.
|
||||
return llvm::ConstantPointerNull::get(getPtrToType(DtoType(vd->type)));
|
||||
return llvm::ConstantPointerNull::get(DtoPtrToType(vd->type));
|
||||
}
|
||||
return DtoConstExpInit(vd->loc, vd->type, vd->type->defaultInit(vd->loc));
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ IrTypePointer* IrTypePointer::get(Type* dt)
|
|||
}
|
||||
else
|
||||
{
|
||||
elemType = i1ToI8(voidToI8(DtoType(dt->nextOf())));
|
||||
elemType = DtoMemType(dt->nextOf());
|
||||
|
||||
// DtoType could have already created the same type, e.g. for
|
||||
// dt == Node* in struct Node { Node* n; }.
|
||||
|
@ -212,7 +212,7 @@ llvm::Type * IrTypeSArray::sarray2llvm(Type * t)
|
|||
assert(t->ty == Tsarray && "not static array type");
|
||||
TypeSArray* tsa = static_cast<TypeSArray*>(t);
|
||||
uint64_t dim = static_cast<uint64_t>(tsa->dim->toUInteger());
|
||||
LLType* elemType = i1ToI8(voidToI8(DtoType(t->nextOf())));
|
||||
LLType* elemType = DtoMemType(t->nextOf());
|
||||
return llvm::ArrayType::get(elemType, dim);
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ IrTypeArray* IrTypeArray::get(Type* dt)
|
|||
assert(!dt->ctype);
|
||||
assert(dt->ty == Tarray && "not dynamic array type");
|
||||
|
||||
LLType* elemType = i1ToI8(voidToI8(DtoType(dt->nextOf())));
|
||||
LLType* elemType = DtoMemType(dt->nextOf());
|
||||
|
||||
// Could have already built the type as part of a struct forward reference,
|
||||
// just as for pointers.
|
||||
|
@ -273,7 +273,7 @@ llvm::Type* IrTypeVector::vector2llvm(Type* dt)
|
|||
assert(tv->basetype->ty == Tsarray);
|
||||
TypeSArray* tsa = static_cast<TypeSArray*>(tv->basetype);
|
||||
uint64_t dim = static_cast<uint64_t>(tsa->dim->toUInteger());
|
||||
LLType* elemType = voidToI8(DtoType(tsa->next));
|
||||
LLType* elemType = DtoMemType(tsa->next);
|
||||
return llvm::VectorType::get(elemType, dim);
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ void AggrTypeBuilder::addAggregate(AggregateDeclaration *ad)
|
|||
}
|
||||
|
||||
// add default type
|
||||
m_defaultTypes.push_back(i1ToI8(DtoType(vd->type)));
|
||||
m_defaultTypes.push_back(DtoMemType(vd->type));
|
||||
|
||||
// advance offset to right past this field
|
||||
m_offset += getMemberSize(vd->type);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue