[cfe-commits] r46734 - /cfe/trunk/CodeGen/CodeGenTypes.cpp

Devang Patel dpatel at apple.com
Mon Feb 4 17:40:48 PST 2008


Author: dpatel
Date: Mon Feb  4 19:40:48 2008
New Revision: 46734

URL: http://llvm.org/viewvc/llvm-project?rev=46734&view=rev
Log:
Keep track of padding fields.

Modified:
    cfe/trunk/CodeGen/CodeGenTypes.cpp

Modified: cfe/trunk/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.cpp?rev=46734&r1=46733&r2=46734&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.cpp Mon Feb  4 19:40:48 2008
@@ -41,7 +41,7 @@
 
     /// addLLVMField - Add llvm struct field that corresponds to llvm type Ty. 
     /// Increment field count.
-    void addLLVMField(const llvm::Type *Ty);
+    void addLLVMField(const llvm::Type *Ty, bool isPaddingField = false);
 
     /// addPaddingFields - Current cursor is not suitable place to add next 
     /// field. Add required padding fields.
@@ -66,6 +66,10 @@
     /// placeBitField - Find a place for FD, which is a bit-field. 
     void placeBitField(const FieldDecl *FD);
 
+    llvm::SmallVector<unsigned, 8> &getPaddingFields() {
+      return PaddingFields;
+    }
+
   private:
     CodeGenTypes &CGT;
     llvm::Type *STy;
@@ -75,6 +79,7 @@
     llvm::SmallVector<const FieldDecl *, 8> FieldDecls;
     std::vector<const llvm::Type*> LLVMFields;
     llvm::SmallVector<uint64_t, 8> Offsets;
+    llvm::SmallVector<unsigned, 8> PaddingFields;
   };
 }
 
@@ -494,12 +499,12 @@
   unsigned RequiredBits = WaterMark - llvmSize;
   unsigned RequiredBytes = (RequiredBits + 7) / 8;
   for (unsigned i = 0; i != RequiredBytes; ++i)
-    addLLVMField(llvm::Type::Int8Ty);
+    addLLVMField(llvm::Type::Int8Ty, true);
 }
 
 /// addLLVMField - Add llvm struct field that corresponds to llvm type Ty.
 /// Increment field count.
-void RecordOrganizer::addLLVMField(const llvm::Type *Ty) {
+void RecordOrganizer::addLLVMField(const llvm::Type *Ty, bool isPaddingField) {
 
   unsigned AlignmentInBits = CGT.getTargetData().getABITypeAlignment(Ty) * 8;
   if (llvmSize % AlignmentInBits) {
@@ -514,6 +519,8 @@
   unsigned TySize = CGT.getTargetData().getABITypeSizeInBits(Ty);
   Offsets.push_back(llvmSize);
   llvmSize += TySize;
+  if (isPaddingField)
+    PaddingFields.push_back(llvmFieldNo);
   LLVMFields.push_back(Ty);
   ++llvmFieldNo;
 }





More information about the cfe-commits mailing list