Prepare StructLayout and StructLayoutBuilder for non-fixed layouts.

Swift SVN r4900
This commit is contained in:
John McCall
2013-04-25 01:39:45 +00:00
parent 80a82b6849
commit 03c04d04df
4 changed files with 35 additions and 24 deletions

View File

@@ -78,12 +78,12 @@ StructLayout::StructLayout(IRGenModule &IGM, LayoutKind layoutKind,
// assertions.
if (!nonEmpty) {
assert(!builder.empty() == requiresHeapHeader(layoutKind));
Align = Alignment(1);
TotalSize = Size(0);
MinimumAlign = Alignment(1);
MinimumSize = Size(0);
Ty = (typeToFill ? typeToFill : IGM.OpaquePtrTy->getElementType());
} else {
Align = builder.getAlignment();
TotalSize = builder.getSize();
MinimumAlign = builder.getAlignment();
MinimumSize = builder.getSize();
if (typeToFill) {
builder.setAsBodyOfStruct(typeToFill);
Ty = typeToFill;
@@ -95,13 +95,13 @@ StructLayout::StructLayout(IRGenModule &IGM, LayoutKind layoutKind,
}
llvm::Value *StructLayout::emitSize(IRGenFunction &IGF) const {
assert(hasStaticLayout());
return llvm::ConstantInt::get(IGF.IGM.SizeTy, getSize().getValue());
assert(isFixedLayout());
return IGF.IGM.getSize(getSize());
}
llvm::Value *StructLayout::emitAlign(IRGenFunction &IGF) const {
assert(hasStaticLayout());
return llvm::ConstantInt::get(IGF.IGM.SizeTy, getAlignment().getValue());
assert(isFixedLayout());
return IGF.IGM.getSize(getAlignment().asSize());
}
/// Bitcast an arbitrary pointer to be a pointer to this type.