Store bools as i8.

I really hope we can refactor this to use a less leaky
abstraction later – it should at least be possible to merge
voidToI8 and i1ToI8.
This commit is contained in:
David Nadlinger
2013-06-06 21:14:46 +02:00
parent 7e92984ebe
commit 848dee32d4
16 changed files with 105 additions and 60 deletions

View File

@@ -188,9 +188,9 @@ IrTypePointer* IrTypePointer::get(Type* dt)
}
}
elemType = DtoTypeNotVoid(dt->nextOf());
elemType = i1ToI8(voidToI8(DtoType(dt->nextOf())));
// DtoTypeNotVoid could have already created the same type, e.g. for
// DtoType could have already created the same type, e.g. for
// dt == Node* in struct Node { Node* n; }.
if (dt->irtype)
return dt->irtype->isPointer();
@@ -226,9 +226,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 = DtoType(t->nextOf());
if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext());
LLType* elemType = i1ToI8(voidToI8(DtoType(t->nextOf())));
return llvm::ArrayType::get(elemType, dim);
}
@@ -248,7 +246,7 @@ IrTypeArray* IrTypeArray::get(Type* dt)
assert(!dt->irtype);
assert(dt->ty == Tarray && "not dynamic array type");
LLType* elemType = DtoTypeNotVoid(dt->nextOf());
LLType* elemType = i1ToI8(voidToI8(DtoType(dt->nextOf())));
// Could have already built the type as part of a struct forward reference,
// just as for pointers.
@@ -289,9 +287,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 = DtoType(tsa->next);
if (elemType == llvm::Type::getVoidTy(llvm::getGlobalContext()))
elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext());
LLType* elemType = voidToI8(DtoType(tsa->next));
return llvm::VectorType::get(elemType, dim);
}