uint64_t Size;
unsigned Align;
switch (T->getTypeClass()) {
+ case Type::TypeName: assert(0 && "Not a canonical type!");
case Type::FunctionNoProto:
case Type::FunctionProto:
assert(0 && "Incomplete types have no size!");
default:
- case Type::Array:
- case Type::Vector:
- case Type::TypeName:
- assert(0 && "Unimplemented type sizes!");
+ case Type::Array: {
+ std::pair<uint64_t, unsigned> EltInfo =
+ getTypeInfo(cast<ArrayType>(T)->getElementType(), L);
+
+ // Get the size of the array.
+ llvm::APSInt Size(32);
+ if (!cast<ArrayType>(T)->getSizeExpr()->isIntegerConstantExpr(Size, *this))
+ assert(0 && "VLAs not implemented yet!");
+
+ Size = EltInfo.first*Size.getZExtValue();
+ Align = EltInfo.second;
+ break;
+ }
+ case Type::Vector: {
+ std::pair<uint64_t, unsigned> EltInfo =
+ getTypeInfo(cast<VectorType>(T)->getElementType(), L);
+ Size = EltInfo.first*cast<VectorType>(T)->getNumElements();
+ // FIXME: Vector alignment is not the alignment of its elements.
+ Align = EltInfo.second;
+ break;
+ }
case Type::Builtin: {
// FIXME: need to use TargetInfo to derive the target specific sizes. This