Convert RecordLayout::NonVirtualSize from bit units to CharUnits.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124646 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ken Dyck 2011-02-01 01:52:10 +00:00
Родитель 65e7a9e059
Коммит 5c3633fa57
6 изменённых файлов: 23 добавлений и 17 удалений

Просмотреть файл

@ -52,7 +52,7 @@ class ASTRecordLayout {
struct CXXRecordLayoutInfo { struct CXXRecordLayoutInfo {
/// NonVirtualSize - The non-virtual size (in bits) of an object, which is /// NonVirtualSize - The non-virtual size (in bits) of an object, which is
/// the size of the object without virtual bases. /// the size of the object without virtual bases.
uint64_t NonVirtualSize; CharUnits NonVirtualSize;
/// NonVirtualAlign - The non-virtual alignment (in bits) of an object, /// NonVirtualAlign - The non-virtual alignment (in bits) of an object,
/// which is the alignment of the object without virtual bases. /// which is the alignment of the object without virtual bases.
@ -91,7 +91,7 @@ class ASTRecordLayout {
ASTRecordLayout(const ASTContext &Ctx, ASTRecordLayout(const ASTContext &Ctx,
uint64_t size, unsigned alignment, uint64_t datasize, uint64_t size, unsigned alignment, uint64_t datasize,
const uint64_t *fieldoffsets, unsigned fieldcount, const uint64_t *fieldoffsets, unsigned fieldcount,
uint64_t nonvirtualsize, unsigned nonvirtualalign, CharUnits nonvirtualsize, unsigned nonvirtualalign,
CharUnits SizeOfLargestEmptySubobject, CharUnits SizeOfLargestEmptySubobject,
const CXXRecordDecl *PrimaryBase, const CXXRecordDecl *PrimaryBase,
bool IsPrimaryBaseVirtual, bool IsPrimaryBaseVirtual,
@ -128,9 +128,9 @@ public:
return DataSize; return DataSize;
} }
/// getNonVirtualSize - Get the non-virtual size (in bits) of an object, /// getNonVirtualSize - Get the non-virtual size (in chars) of an object,
/// which is the size of the object without virtual bases. /// which is the size of the object without virtual bases.
uint64_t getNonVirtualSize() const { CharUnits getNonVirtualSize() const {
assert(CXXInfo && "Record layout does not have C++ specific info!"); assert(CXXInfo && "Record layout does not have C++ specific info!");
return CXXInfo->NonVirtualSize; return CXXInfo->NonVirtualSize;

Просмотреть файл

@ -52,7 +52,9 @@ public:
return false; return false;
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD); const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
return Layout.getNonVirtualSize() == Context.Target.getPointerWidth(0); CharUnits PointerSize =
Context.toCharUnitsFromBits(Context.Target.getPointerWidth(0));
return Layout.getNonVirtualSize() == PointerSize;
} }
}; };

Просмотреть файл

@ -44,8 +44,10 @@ public:
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD); const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
// In the Microsoft ABI, classes can have one or two vtable pointers. // In the Microsoft ABI, classes can have one or two vtable pointers.
return Layout.getNonVirtualSize() == Context.Target.getPointerWidth(0) || CharUnits PointerSize =
Layout.getNonVirtualSize() == Context.Target.getPointerWidth(0) * 2; Context.toCharUnitsFromBits(Context.Target.getPointerWidth(0));
return Layout.getNonVirtualSize() == PointerSize ||
Layout.getNonVirtualSize() == PointerSize * 2;
} }
}; };
} }

Просмотреть файл

@ -45,7 +45,7 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
uint64_t datasize, uint64_t datasize,
const uint64_t *fieldoffsets, const uint64_t *fieldoffsets,
unsigned fieldcount, unsigned fieldcount,
uint64_t nonvirtualsize, CharUnits nonvirtualsize,
unsigned nonvirtualalign, unsigned nonvirtualalign,
CharUnits SizeOfLargestEmptySubobject, CharUnits SizeOfLargestEmptySubobject,
const CXXRecordDecl *PrimaryBase, const CXXRecordDecl *PrimaryBase,

Просмотреть файл

@ -1115,7 +1115,8 @@ CharUnits RecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
if (!Base->Class->isEmpty()) { if (!Base->Class->isEmpty()) {
// Update the data size. // Update the data size.
DataSize = Offset + Layout.getNonVirtualSize(); DataSize = Offset +
(Layout.getNonVirtualSize().getQuantity() * Context.getCharWidth());
Size = std::max(Size, DataSize); Size = std::max(Size, DataSize);
} else } else
@ -1665,7 +1666,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
new (*this) ASTRecordLayout(*this, Builder->Size, Builder->Alignment, new (*this) ASTRecordLayout(*this, Builder->Size, Builder->Alignment,
DataSize, Builder->FieldOffsets.data(), DataSize, Builder->FieldOffsets.data(),
Builder->FieldOffsets.size(), Builder->FieldOffsets.size(),
NonVirtualSize, toCharUnitsFromBits(NonVirtualSize),
Builder->NonVirtualAlignment, Builder->NonVirtualAlignment,
EmptySubobjects.SizeOfLargestEmptySubobject, EmptySubobjects.SizeOfLargestEmptySubobject,
Builder->PrimaryBase, Builder->PrimaryBase,
@ -1834,7 +1835,7 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS,
OS << " sizeof=" << Layout.getSize() / 8; OS << " sizeof=" << Layout.getSize() / 8;
OS << ", dsize=" << Layout.getDataSize() / 8; OS << ", dsize=" << Layout.getDataSize() / 8;
OS << ", align=" << Layout.getAlignment() / 8 << '\n'; OS << ", align=" << Layout.getAlignment() / 8 << '\n';
OS << " nvsize=" << Layout.getNonVirtualSize() / 8; OS << " nvsize=" << Layout.getNonVirtualSize().getQuantity();
OS << ", nvalign=" << Layout.getNonVirtualAlign() / 8 << '\n'; OS << ", nvalign=" << Layout.getNonVirtualAlign() / 8 << '\n';
OS << '\n'; OS << '\n';
} }

Просмотреть файл

@ -500,12 +500,12 @@ void CGRecordLayoutBuilder::LayoutBase(const CXXRecordDecl *BaseDecl,
const ASTRecordLayout &Layout = const ASTRecordLayout &Layout =
Types.getContext().getASTRecordLayout(BaseDecl); Types.getContext().getASTRecordLayout(BaseDecl);
uint64_t NonVirtualSize = Layout.getNonVirtualSize(); CharUnits NonVirtualSize = Layout.getNonVirtualSize();
AppendPadding(BaseOffset / 8, 1); AppendPadding(BaseOffset / 8, 1);
// FIXME: Actually use a better type than [sizeof(BaseDecl) x i8] when we can. // FIXME: Actually use a better type than [sizeof(BaseDecl) x i8] when we can.
AppendBytes(NonVirtualSize / 8); AppendBytes(NonVirtualSize.getQuantity());
} }
void void
@ -520,12 +520,12 @@ CGRecordLayoutBuilder::LayoutVirtualBase(const CXXRecordDecl *BaseDecl,
const ASTRecordLayout &Layout = const ASTRecordLayout &Layout =
Types.getContext().getASTRecordLayout(BaseDecl); Types.getContext().getASTRecordLayout(BaseDecl);
uint64_t NonVirtualSize = Layout.getNonVirtualSize(); CharUnits NonVirtualSize = Layout.getNonVirtualSize();
AppendPadding(BaseOffset / 8, 1); AppendPadding(BaseOffset / 8, 1);
// FIXME: Actually use a better type than [sizeof(BaseDecl) x i8] when we can. // FIXME: Actually use a better type than [sizeof(BaseDecl) x i8] when we can.
AppendBytes(NonVirtualSize / 8); AppendBytes(NonVirtualSize.getQuantity());
// FIXME: Add the vbase field info. // FIXME: Add the vbase field info.
} }
@ -616,8 +616,9 @@ bool
CGRecordLayoutBuilder::ComputeNonVirtualBaseType(const CXXRecordDecl *RD) { CGRecordLayoutBuilder::ComputeNonVirtualBaseType(const CXXRecordDecl *RD) {
const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(RD); const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(RD);
uint64_t AlignedNonVirtualTypeSize = uint64_t AlignedNonVirtualTypeSize =
llvm::RoundUpToAlignment(Layout.getNonVirtualSize(), llvm::RoundUpToAlignment(Layout.getNonVirtualSize().getQuantity() * 8,
Layout.getNonVirtualAlign()) / 8; Layout.getNonVirtualAlign()) / 8;
@ -855,7 +856,7 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) {
if (BaseTy) { if (BaseTy) {
uint64_t AlignedNonVirtualTypeSizeInBits = uint64_t AlignedNonVirtualTypeSizeInBits =
llvm::RoundUpToAlignment(Layout.getNonVirtualSize(), llvm::RoundUpToAlignment(Layout.getNonVirtualSize().getQuantity() * 8,
Layout.getNonVirtualAlign()); Layout.getNonVirtualAlign());
assert(AlignedNonVirtualTypeSizeInBits == assert(AlignedNonVirtualTypeSizeInBits ==