[cfe-commits] r124646 - in /cfe/trunk: include/clang/AST/RecordLayout.h lib/AST/ItaniumCXXABI.cpp lib/AST/MicrosoftCXXABI.cpp lib/AST/RecordLayout.cpp lib/AST/RecordLayoutBuilder.cpp lib/CodeGen/CGRecordLayoutBuilder.cpp

Ken Dyck kd at kendyck.com
Mon Jan 31 17:52:10 PST 2011


Author: kjdyck
Date: Mon Jan 31 19:52:10 2011
New Revision: 124646

URL: http://llvm.org/viewvc/llvm-project?rev=124646&view=rev
Log:
Convert RecordLayout::NonVirtualSize from bit units to CharUnits.

Modified:
    cfe/trunk/include/clang/AST/RecordLayout.h
    cfe/trunk/lib/AST/ItaniumCXXABI.cpp
    cfe/trunk/lib/AST/MicrosoftCXXABI.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=124646&r1=124645&r2=124646&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecordLayout.h (original)
+++ cfe/trunk/include/clang/AST/RecordLayout.h Mon Jan 31 19:52:10 2011
@@ -52,7 +52,7 @@
   struct CXXRecordLayoutInfo {
     /// NonVirtualSize - The non-virtual size (in bits) of an object, which is
     /// the size of the object without virtual bases.
-    uint64_t NonVirtualSize;
+    CharUnits NonVirtualSize;
 
     /// NonVirtualAlign - The non-virtual alignment (in bits) of an object,
     /// which is the alignment of the object without virtual bases.
@@ -91,7 +91,7 @@
   ASTRecordLayout(const ASTContext &Ctx,
                   uint64_t size, unsigned alignment, uint64_t datasize,
                   const uint64_t *fieldoffsets, unsigned fieldcount,
-                  uint64_t nonvirtualsize, unsigned nonvirtualalign,
+                  CharUnits nonvirtualsize, unsigned nonvirtualalign,
                   CharUnits SizeOfLargestEmptySubobject,
                   const CXXRecordDecl *PrimaryBase,
                   bool IsPrimaryBaseVirtual,
@@ -128,9 +128,9 @@
     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.
-  uint64_t getNonVirtualSize() const {
+  CharUnits getNonVirtualSize() const {
     assert(CXXInfo && "Record layout does not have C++ specific info!");
 
     return CXXInfo->NonVirtualSize;

Modified: cfe/trunk/lib/AST/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumCXXABI.cpp?rev=124646&r1=124645&r2=124646&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumCXXABI.cpp Mon Jan 31 19:52:10 2011
@@ -52,7 +52,9 @@
       return false;
 
     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;
   }
 };
 

Modified: cfe/trunk/lib/AST/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftCXXABI.cpp?rev=124646&r1=124645&r2=124646&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftCXXABI.cpp Mon Jan 31 19:52:10 2011
@@ -44,8 +44,10 @@
     const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
     
     // In the Microsoft ABI, classes can have one or two vtable pointers.
-    return Layout.getNonVirtualSize() == Context.Target.getPointerWidth(0) ||
-      Layout.getNonVirtualSize() == Context.Target.getPointerWidth(0) * 2;
+    CharUnits PointerSize = 
+      Context.toCharUnitsFromBits(Context.Target.getPointerWidth(0));
+    return Layout.getNonVirtualSize() == PointerSize ||
+      Layout.getNonVirtualSize() == PointerSize * 2;
   }    
 };
 }

Modified: cfe/trunk/lib/AST/RecordLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayout.cpp?rev=124646&r1=124645&r2=124646&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayout.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayout.cpp Mon Jan 31 19:52:10 2011
@@ -45,7 +45,7 @@
                                  uint64_t datasize,
                                  const uint64_t *fieldoffsets,
                                  unsigned fieldcount,
-                                 uint64_t nonvirtualsize,
+                                 CharUnits nonvirtualsize,
                                  unsigned nonvirtualalign,
                                  CharUnits SizeOfLargestEmptySubobject,
                                  const CXXRecordDecl *PrimaryBase,

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=124646&r1=124645&r2=124646&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Mon Jan 31 19:52:10 2011
@@ -1115,7 +1115,8 @@
 
   if (!Base->Class->isEmpty()) {
     // Update the data size.
-    DataSize = Offset + Layout.getNonVirtualSize();
+    DataSize = Offset + 
+      (Layout.getNonVirtualSize().getQuantity() * Context.getCharWidth());
 
     Size = std::max(Size, DataSize);
   } else
@@ -1665,7 +1666,7 @@
       new (*this) ASTRecordLayout(*this, Builder->Size, Builder->Alignment,
                                   DataSize, Builder->FieldOffsets.data(),
                                   Builder->FieldOffsets.size(),
-                                  NonVirtualSize,
+                                  toCharUnitsFromBits(NonVirtualSize),
                                   Builder->NonVirtualAlignment,
                                   EmptySubobjects.SizeOfLargestEmptySubobject,
                                   Builder->PrimaryBase,
@@ -1834,7 +1835,7 @@
   OS << "  sizeof=" << Layout.getSize() / 8;
   OS << ", dsize=" << Layout.getDataSize() / 8;
   OS << ", align=" << Layout.getAlignment() / 8 << '\n';
-  OS << "  nvsize=" << Layout.getNonVirtualSize() / 8;
+  OS << "  nvsize=" << Layout.getNonVirtualSize().getQuantity();
   OS << ", nvalign=" << Layout.getNonVirtualAlign() / 8 << '\n';
   OS << '\n';
 }

Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=124646&r1=124645&r2=124646&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Mon Jan 31 19:52:10 2011
@@ -500,12 +500,12 @@
   const ASTRecordLayout &Layout = 
     Types.getContext().getASTRecordLayout(BaseDecl);
   
-  uint64_t NonVirtualSize = Layout.getNonVirtualSize();
+  CharUnits NonVirtualSize = Layout.getNonVirtualSize();
   
   AppendPadding(BaseOffset / 8, 1);
   
   // FIXME: Actually use a better type than [sizeof(BaseDecl) x i8] when we can.
-  AppendBytes(NonVirtualSize / 8);
+  AppendBytes(NonVirtualSize.getQuantity());
 }
 
 void
@@ -520,12 +520,12 @@
   const ASTRecordLayout &Layout = 
     Types.getContext().getASTRecordLayout(BaseDecl);
 
-  uint64_t NonVirtualSize = Layout.getNonVirtualSize();
+  CharUnits NonVirtualSize = Layout.getNonVirtualSize();
 
   AppendPadding(BaseOffset / 8, 1);
   
   // 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.
 }
@@ -616,8 +616,9 @@
 CGRecordLayoutBuilder::ComputeNonVirtualBaseType(const CXXRecordDecl *RD) {
   const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(RD);
 
+
   uint64_t AlignedNonVirtualTypeSize =
-    llvm::RoundUpToAlignment(Layout.getNonVirtualSize(),
+    llvm::RoundUpToAlignment(Layout.getNonVirtualSize().getQuantity() * 8,
                              Layout.getNonVirtualAlign()) / 8;
   
   
@@ -855,7 +856,7 @@
 
   if (BaseTy) {
     uint64_t AlignedNonVirtualTypeSizeInBits =
-      llvm::RoundUpToAlignment(Layout.getNonVirtualSize(),
+      llvm::RoundUpToAlignment(Layout.getNonVirtualSize().getQuantity() * 8,
                                Layout.getNonVirtualAlign());
 
     assert(AlignedNonVirtualTypeSizeInBits == 





More information about the cfe-commits mailing list