[cfe-commits] r125549 - in /cfe/trunk: include/clang/AST/RecordLayout.h lib/AST/ASTContext.cpp lib/AST/RecordLayout.cpp lib/AST/RecordLayoutBuilder.cpp lib/CodeGen/CGRecordLayoutBuilder.cpp
Ken Dyck
kd at kendyck.com
Mon Feb 14 18:32:41 PST 2011
Author: kjdyck
Date: Mon Feb 14 20:32:40 2011
New Revision: 125549
URL: http://llvm.org/viewvc/llvm-project?rev=125549&view=rev
Log:
Convert RecordLayout::Alignment to CharUnits from bit units. No change in
functionality intended.
Modified:
cfe/trunk/include/clang/AST/RecordLayout.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/RecordLayout.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Modified: cfe/trunk/include/clang/AST/RecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecordLayout.h?rev=125549&r1=125548&r2=125549&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecordLayout.h (original)
+++ cfe/trunk/include/clang/AST/RecordLayout.h Mon Feb 14 20:32:40 2011
@@ -42,8 +42,8 @@
/// FieldOffsets - Array of field offsets in bits.
uint64_t *FieldOffsets;
- // Alignment - Alignment of record in bits.
- unsigned Alignment;
+ // Alignment - Alignment of record in characters.
+ CharUnits Alignment;
// FieldCount - Number of fields.
unsigned FieldCount;
@@ -82,14 +82,14 @@
friend class ASTContext;
- ASTRecordLayout(const ASTContext &Ctx, CharUnits size, unsigned alignment,
+ ASTRecordLayout(const ASTContext &Ctx, CharUnits size, CharUnits alignment,
CharUnits datasize, const uint64_t *fieldoffsets,
unsigned fieldcount);
// Constructor for C++ records.
typedef CXXRecordLayoutInfo::BaseOffsetsMapTy BaseOffsetsMapTy;
ASTRecordLayout(const ASTContext &Ctx,
- CharUnits size, unsigned alignment, CharUnits datasize,
+ CharUnits size, CharUnits alignment, CharUnits datasize,
const uint64_t *fieldoffsets, unsigned fieldcount,
CharUnits nonvirtualsize, CharUnits nonvirtualalign,
CharUnits SizeOfLargestEmptySubobject,
@@ -106,8 +106,8 @@
void operator=(const ASTRecordLayout&); // DO NOT IMPLEMENT
public:
- /// getAlignment - Get the record alignment in bits.
- unsigned getAlignment() const { return Alignment; }
+ /// getAlignment - Get the record alignment in characters.
+ CharUnits getAlignment() const { return Alignment; }
/// getSize - Get the record size in characters.
CharUnits getSize() const { return Size; }
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=125549&r1=125548&r2=125549&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 14 20:32:40 2011
@@ -632,7 +632,7 @@
const ASTRecordLayout &layout = getASTRecordLayout(field->getParent());
// Start with the record's overall alignment.
- unsigned fieldAlign = layout.getAlignment();
+ unsigned fieldAlign = toBits(layout.getAlignment());
// Use the GCD of that and the offset within the record.
uint64_t offset = layout.getFieldOffset(field->getFieldIndex());
@@ -848,7 +848,7 @@
const ObjCInterfaceType *ObjCI = cast<ObjCInterfaceType>(T);
const ASTRecordLayout &Layout = getASTObjCInterfaceLayout(ObjCI->getDecl());
Width = toBits(Layout.getSize());
- Align = Layout.getAlignment();
+ Align = toBits(Layout.getAlignment());
break;
}
case Type::Record:
@@ -867,7 +867,7 @@
const RecordType *RT = cast<RecordType>(TT);
const ASTRecordLayout &Layout = getASTRecordLayout(RT->getDecl());
Width = toBits(Layout.getSize());
- Align = Layout.getAlignment();
+ Align = toBits(Layout.getAlignment());
break;
}
Modified: cfe/trunk/lib/AST/RecordLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayout.cpp?rev=125549&r1=125548&r2=125549&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayout.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayout.cpp Mon Feb 14 20:32:40 2011
@@ -28,7 +28,7 @@
}
ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size,
- unsigned alignment, CharUnits datasize,
+ CharUnits alignment, CharUnits datasize,
const uint64_t *fieldoffsets,
unsigned fieldcount)
: Size(size), DataSize(datasize), FieldOffsets(0), Alignment(alignment),
@@ -41,7 +41,7 @@
// Constructor for C++ records.
ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
- CharUnits size, unsigned alignment,
+ CharUnits size, CharUnits alignment,
CharUnits datasize,
const uint64_t *fieldoffsets,
unsigned fieldcount,
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=125549&r1=125548&r2=125549&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Mon Feb 14 20:32:40 2011
@@ -1203,7 +1203,7 @@
if (ObjCInterfaceDecl *SD = D->getSuperClass()) {
const ASTRecordLayout &SL = Context.getASTObjCInterfaceLayout(SD);
- UpdateAlignment(SL.getAlignment());
+ UpdateAlignment(Context.toBits(SL.getAlignment()));
// We start laying out ivars not at the end of the superclass
// structure, but at the next byte following the last field.
@@ -1683,7 +1683,8 @@
CharUnits RecordSize = toCharUnitsFromBits(Builder->Size);
NewEntry =
- new (*this) ASTRecordLayout(*this, RecordSize, Builder->Alignment,
+ new (*this) ASTRecordLayout(*this, RecordSize,
+ toCharUnitsFromBits(Builder->Alignment),
toCharUnitsFromBits(DataSize),
Builder->FieldOffsets.data(),
Builder->FieldOffsets.size(),
@@ -1700,7 +1701,8 @@
CharUnits RecordSize = toCharUnitsFromBits(Builder.Size);
NewEntry =
- new (*this) ASTRecordLayout(*this, RecordSize, Builder.Alignment,
+ new (*this) ASTRecordLayout(*this, RecordSize,
+ toCharUnitsFromBits(Builder.Alignment),
toCharUnitsFromBits(Builder.Size),
Builder.FieldOffsets.data(),
Builder.FieldOffsets.size());
@@ -1760,7 +1762,8 @@
CharUnits RecordSize = toCharUnitsFromBits(Builder.Size);
const ASTRecordLayout *NewEntry =
- new (*this) ASTRecordLayout(*this, RecordSize, Builder.Alignment,
+ new (*this) ASTRecordLayout(*this, RecordSize,
+ toCharUnitsFromBits(Builder.Alignment),
toCharUnitsFromBits(Builder.DataSize),
Builder.FieldOffsets.data(),
Builder.FieldOffsets.size());
@@ -1859,7 +1862,7 @@
OS << " sizeof=" << Layout.getSize().getQuantity();
OS << ", dsize=" << Layout.getDataSize().getQuantity();
- OS << ", align=" << Layout.getAlignment() / 8 << '\n';
+ OS << ", align=" << Layout.getAlignment().getQuantity() << '\n';
OS << " nvsize=" << Layout.getNonVirtualSize().getQuantity();
OS << ", nvalign=" << Layout.getNonVirtualAlign().getQuantity() << '\n';
OS << '\n';
@@ -1880,7 +1883,7 @@
OS << "<ASTRecordLayout\n";
OS << " Size:" << toBits(Info.getSize()) << "\n";
OS << " DataSize:" << toBits(Info.getDataSize()) << "\n";
- OS << " Alignment:" << Info.getAlignment() << "\n";
+ OS << " Alignment:" << toBits(Info.getAlignment()) << "\n";
OS << " FieldOffsets: [";
for (unsigned i = 0, e = Info.getFieldCount(); i != e; ++i) {
if (i) OS << ", ";
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=125549&r1=125548&r2=125549&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Mon Feb 14 20:32:40 2011
@@ -177,7 +177,8 @@
}
void CGRecordLayoutBuilder::Layout(const RecordDecl *D) {
- Alignment = Types.getContext().getASTRecordLayout(D).getAlignment() / 8;
+ Alignment =
+ Types.getContext().getASTRecordLayout(D).getAlignment().getQuantity();
Packed = D->hasAttr<PackedAttr>();
if (D->isUnion()) {
@@ -301,7 +302,7 @@
const RecordDecl *RD = FD->getParent();
const ASTRecordLayout &RL = Types.getContext().getASTRecordLayout(RD);
uint64_t ContainingTypeSizeInBits = Types.getContext().toBits(RL.getSize());
- unsigned ContainingTypeAlign = RL.getAlignment();
+ unsigned ContainingTypeAlign = Types.getContext().toBits(RL.getAlignment());
return MakeInfo(Types, FD, FieldOffset, FieldSize, ContainingTypeSizeInBits,
ContainingTypeAlign);
@@ -476,7 +477,7 @@
if (Ty) {
AppendField(0, Ty);
- if (getTypeAlignment(Ty) > Layout.getAlignment() / 8) {
+ if (getTypeAlignment(Ty) > Layout.getAlignment().getQuantity()) {
// We need a packed struct.
Packed = true;
Align = 1;
More information about the cfe-commits
mailing list