[cfe-commits] r43619 - in /cfe/trunk: AST/ASTContext.cpp CodeGen/CodeGenFunction.cpp CodeGen/CodeGenFunction.h CodeGen/CodeGenTypes.cpp CodeGen/CodeGenTypes.h include/clang/AST/ASTContext.h include/clang/AST/RecordLayout.h

Devang Patel dpatel at apple.com
Thu Nov 1 12:11:02 PDT 2007


Author: dpatel
Date: Thu Nov  1 14:11:01 2007
New Revision: 43619

URL: http://llvm.org/viewvc/llvm-project?rev=43619&view=rev
Log:
Rename classes and collections that maintain record layout information.
Now, at AST level record info is maintained by ASTRecordLayout class.
Now, at code gen  level record info is maintained by CGRecordLayout class.

Modified:
    cfe/trunk/AST/ASTContext.cpp
    cfe/trunk/CodeGen/CodeGenFunction.cpp
    cfe/trunk/CodeGen/CodeGenFunction.h
    cfe/trunk/CodeGen/CodeGenTypes.cpp
    cfe/trunk/CodeGen/CodeGenTypes.h
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/include/clang/AST/RecordLayout.h

Modified: cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=43619&r1=43618&r2=43619&view=diff

==============================================================================
--- cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/trunk/AST/ASTContext.cpp Thu Nov  1 14:11:01 2007
@@ -246,7 +246,7 @@
   case Type::Tagged:
     TagType *TT = cast<TagType>(T);
     if (RecordType *RT = dyn_cast<RecordType>(TT)) {
-      const RecordLayout &Layout = getRecordLayout(RT->getDecl(), L);
+      const ASTRecordLayout &Layout = getASTRecordLayout(RT->getDecl(), L);
       Size = Layout.getSize();
       Align = Layout.getAlignment();
     } else if (EnumDecl *ED = dyn_cast<EnumDecl>(TT->getDecl())) {
@@ -261,20 +261,20 @@
   return std::make_pair(Size, Align);
 }
 
-/// getRecordLayout - Get or compute information about the layout of the
+/// getASTRecordLayout - Get or compute information about the layout of the
 /// specified record (struct/union/class), which indicates its size and field
 /// position information.
-const RecordLayout &ASTContext::getRecordLayout(const RecordDecl *D,
-                                                SourceLocation L) {
+const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D,
+                                                      SourceLocation L) {
   assert(D->isDefinition() && "Cannot get layout of forward declarations!");
   
   // Look up this layout, if already laid out, return what we have.
-  const RecordLayout *&Entry = RecordLayoutInfo[D];
+  const ASTRecordLayout *&Entry = ASTRecordLayouts[D];
   if (Entry) return *Entry;
   
-  // Allocate and assign into RecordLayoutInfo here.  The "Entry" reference can
-  // be invalidated (dangle) if the RecordLayoutInfo hashtable is inserted into.
-  RecordLayout *NewEntry = new RecordLayout();
+  // Allocate and assign into ASTRecordLayouts here.  The "Entry" reference can
+  // be invalidated (dangle) if the ASTRecordLayouts hashtable is inserted into.
+  ASTRecordLayout *NewEntry = new ASTRecordLayout();
   Entry = NewEntry;
   
   uint64_t *FieldOffsets = new uint64_t[D->getNumMembers()];

Modified: cfe/trunk/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenFunction.cpp?rev=43619&r1=43618&r2=43619&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenFunction.cpp Thu Nov  1 14:11:01 2007
@@ -126,14 +126,14 @@
     BB->setName(N);
 }
 
-/// getRecordLayoutInfo - Return record layout info.
-const RecordLayoutInfo *CodeGenFunction::getRecordLayoutInfo(CodeGenTypes &CGT,
-                                                       QualType RTy) {
+/// getCGRecordLayout - Return record layout info.
+const CGRecordLayout *CodeGenFunction::getCGRecordLayout(CodeGenTypes &CGT,
+                                                         QualType RTy) {
   assert (isa<RecordType>(RTy) 
           && "Unexpected type. RecordType expected here.");
 
   const llvm::Type *Ty = ConvertType(RTy);
   assert (Ty && "Unable to find llvm::Type");
   
-  return CGT.getRecordLayoutInfo(Ty);
+  return CGT.getCGRecordLayout(Ty);
 }

Modified: cfe/trunk/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenFunction.h?rev=43619&r1=43618&r2=43619&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/CodeGen/CodeGenFunction.h Thu Nov  1 14:11:01 2007
@@ -73,7 +73,7 @@
 namespace CodeGen {
   class CodeGenModule;
   class CodeGenTypes;
-  class RecordLayoutInfo;  
+  class CGRecordLayout;  
 
 /// RValue - This trivial value class is used to represent the result of an
 /// expression that is evaluated.  It can be one of three things: either a
@@ -298,8 +298,8 @@
   /// then reuse it.
   void StartBlock(const char *N);
 
-  /// getRecordLayoutInfo - Return record layout info.
-  const RecordLayoutInfo *getRecordLayoutInfo(CodeGenTypes &CGT, QualType RTy);
+  /// getCGRecordLayout - Return record layout info.
+  const CGRecordLayout *getCGRecordLayout(CodeGenTypes &CGT, QualType RTy);
   //===--------------------------------------------------------------------===//
   //                            Declaration Emission
   //===--------------------------------------------------------------------===//

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

==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.cpp Thu Nov  1 14:11:01 2007
@@ -22,7 +22,7 @@
 using namespace CodeGen;
 
 namespace {
-  /// RecordOrganizer - This helper class, used by RecordLayoutInfo, layouts 
+  /// RecordOrganizer - This helper class, used by CGRecordLayout, layouts 
   /// structs and unions. It manages transient information used during layout.
   /// FIXME : At the moment assume 
   ///    - one to one mapping between AST FieldDecls and 
@@ -49,7 +49,7 @@
     /// layoutStructFields - Do the actual work and lay out all fields. Create
     /// corresponding llvm struct type.  This should be invoked only after
     /// all fields are added.
-    void layoutStructFields(const RecordLayout &RL);
+    void layoutStructFields(const ASTRecordLayout &RL);
 
     /// layoutUnionFields - Do the actual work and lay out all fields. Create
     /// corresponding llvm struct type.  This should be invoked only after
@@ -78,11 +78,11 @@
 }
 
 CodeGenTypes::~CodeGenTypes() {
-  for(llvm::DenseMap<const llvm::Type *, RecordLayoutInfo *>::iterator
-        I = RecordLayouts.begin(), E = RecordLayouts.end();
+  for(llvm::DenseMap<const llvm::Type *, CGRecordLayout *>::iterator
+        I = CGRecordLayouts.begin(), E = CGRecordLayouts.end();
       I != E; ++I)
     delete I->second;
-  RecordLayouts.clear();
+  CGRecordLayouts.clear();
 }
 
 /// ConvertType - Convert the specified type to its LLVM form.
@@ -258,13 +258,13 @@
       RecordOrganizer RO(*this);
       for (unsigned i = 0, e = RD->getNumMembers(); i != e; ++i)
         RO.addField(RD->getMember(i));
-      const RecordLayout &RL = Context.getRecordLayout(RD, SourceLocation());
+      const ASTRecordLayout &RL = Context.getASTRecordLayout(RD, SourceLocation());
       RO.layoutStructFields(RL);
 
       // Get llvm::StructType.
-      RecordLayoutInfo *RLI = new RecordLayoutInfo(RO.getLLVMType());
+      CGRecordLayout *RLI = new CGRecordLayout(RO.getLLVMType());
       ResultType = RLI->getLLVMType();
-      RecordLayouts[ResultType] = RLI;
+      CGRecordLayouts[ResultType] = RLI;
 
       // Refine any OpaqueType associated with this RecordDecl.
       OpaqueTy->refineAbstractTypeTo(ResultType);
@@ -285,9 +285,9 @@
         RO.layoutUnionFields();
 
         // Get llvm::StructType.
-        RecordLayoutInfo *RLI = new RecordLayoutInfo(RO.getLLVMType());
+        CGRecordLayout *RLI = new CGRecordLayout(RO.getLLVMType());
         ResultType = RLI->getLLVMType();
-        RecordLayouts[ResultType] = RLI;
+        CGRecordLayouts[ResultType] = RLI;
       } else {       
         std::vector<const llvm::Type*> Fields;
         ResultType = llvm::StructType::get(Fields);
@@ -339,12 +339,12 @@
   FieldInfo[FD] = No;
 }
 
-/// getRecordLayoutInfo - Return record layout info for the given llvm::Type.
-const RecordLayoutInfo *
-CodeGenTypes::getRecordLayoutInfo(const llvm::Type* Ty) const {
-  llvm::DenseMap<const llvm::Type*, RecordLayoutInfo *>::iterator I
-    = RecordLayouts.find(Ty);
-  assert (I != RecordLayouts.end() 
+/// getCGRecordLayout - Return record layout info for the given llvm::Type.
+const CGRecordLayout *
+CodeGenTypes::getCGRecordLayout(const llvm::Type* Ty) const {
+  llvm::DenseMap<const llvm::Type*, CGRecordLayout *>::iterator I
+    = CGRecordLayouts.find(Ty);
+  assert (I != CGRecordLayouts.end() 
           && "Unable to find record layout information for type");
   return I->second;
 }
@@ -364,7 +364,7 @@
 ///    - Ignore bit fields
 ///    - Ignore field aligments
 ///    - Ignore packed structs
-void RecordOrganizer::layoutStructFields(const RecordLayout &RL) {
+void RecordOrganizer::layoutStructFields(const ASTRecordLayout &RL) {
   // FIXME : Use SmallVector
   Cursor = 0;
   FieldNo = 0;

Modified: cfe/trunk/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.h?rev=43619&r1=43618&r2=43619&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.h Thu Nov  1 14:11:01 2007
@@ -37,12 +37,12 @@
 namespace CodeGen {
   class CodeGenTypes;
 
-  /// RecordLayoutInfo - This class handles struct and union layout info while 
+  /// CGRecordLayout - This class handles struct and union layout info while 
   /// lowering AST types to LLVM types.
-  class RecordLayoutInfo {
-    RecordLayoutInfo(); // DO NOT IMPLEMENT
+  class CGRecordLayout {
+    CGRecordLayout(); // DO NOT IMPLEMENT
   public:
-    RecordLayoutInfo(llvm::Type *T) : STy(T) {
+    CGRecordLayout(llvm::Type *T) : STy(T) {
       // FIXME : Collect info about fields that requires adjustments 
       // (i.e. fields that do not directly map to llvm struct fields.)
     }
@@ -66,11 +66,11 @@
   
   llvm::DenseMap<const TagDecl*, llvm::Type*> TagDeclTypes;
 
-  /// RecordLayouts - This maps llvm struct type with corresponding 
+  /// CGRecordLayouts - This maps llvm struct type with corresponding 
   /// record layout info. 
-  /// FIXME : If RecordLayoutInfo is less than 16 bytes then use 
+  /// FIXME : If CGRecordLayout is less than 16 bytes then use 
   /// inline it in the map.
-  llvm::DenseMap<const llvm::Type*, RecordLayoutInfo *> RecordLayouts;
+  llvm::DenseMap<const llvm::Type*, CGRecordLayout *> CGRecordLayouts;
 
   /// FieldInfo - This maps struct field with corresponding llvm struct type
   /// field no. This info is populated by record organizer.
@@ -106,7 +106,7 @@
   void DecodeArgumentTypes(const FunctionTypeProto &FTP, 
                            std::vector<const llvm::Type*> &ArgTys);
 
-  const RecordLayoutInfo *getRecordLayoutInfo(const llvm::Type*) const;
+  const CGRecordLayout *getCGRecordLayout(const llvm::Type*) const;
   
   /// getLLVMFieldNo - Return llvm::StructType element number
   /// that corresponds to the field FD.

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=43619&r1=43618&r2=43619&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Nov  1 14:11:01 2007
@@ -42,10 +42,9 @@
   llvm::FoldingSet<FunctionTypeNoProto> FunctionTypeNoProtos;
   llvm::FoldingSet<FunctionTypeProto> FunctionTypeProtos;
   llvm::FoldingSet<ObjcQualifiedInterfaceType> ObjcQualifiedInterfaceTypes;
-  
-  /// RecordLayoutInfo - A cache mapping from RecordDecls to RecordLayoutInfo.
+  /// ASTRecordLayouts - A cache mapping from RecordDecls to ASTRecordLayouts.
   ///  This is lazily created.  This is intentionally not serialized.
-  llvm::DenseMap<const RecordDecl*, const RecordLayout*> RecordLayoutInfo;
+  llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*> ASTRecordLayouts;
     
   /// BuiltinVaListType - built-in va list type.
   /// This is initially null and set by Sema::LazilyCreateBuiltin when
@@ -241,10 +240,10 @@
     return getTypeInfo(T, L).second;
   }
   
-  /// getRecordLayout - Get or compute information about the layout of the
+  /// getASTRecordLayout - Get or compute information about the layout of the
   /// specified record (struct/union/class), which indicates its size and field
   /// position information.
-  const RecordLayout &getRecordLayout(const RecordDecl *D, SourceLocation L);
+  const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D, SourceLocation L);
   
   //===--------------------------------------------------------------------===//
   //                            Type Operators

Modified: cfe/trunk/include/clang/AST/RecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecordLayout.h?rev=43619&r1=43618&r2=43619&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/RecordLayout.h (original)
+++ cfe/trunk/include/clang/AST/RecordLayout.h Thu Nov  1 14:11:01 2007
@@ -20,17 +20,17 @@
   class ASTContext;
   class RecordDecl;
 
-/// RecordLayout - This class contains layout information for one RecordDecl,
+/// ASTRecordLayout - This class contains layout information for one RecordDecl,
 /// which is a struct/union/class.  The decl represented must be a definition,
 /// not a forward declaration.  These objects are managed by ASTContext.
-class RecordLayout {
+class ASTRecordLayout {
   uint64_t Size;        // Size of record in bits.
   unsigned Alignment;   // Alignment of record in bits.
   uint64_t *FieldOffsets;
   friend class ASTContext;
   
-  RecordLayout() {}
-  ~RecordLayout() {
+  ASTRecordLayout() {}
+  ~ASTRecordLayout() {
     delete [] FieldOffsets;
   }
   
@@ -39,8 +39,8 @@
     FieldOffsets = fieldOffsets;
   }
   
-  RecordLayout(const RecordLayout&);   // DO NOT IMPLEMENT
-  void operator=(const RecordLayout&); // DO NOT IMPLEMENT
+  ASTRecordLayout(const ASTRecordLayout&);   // DO NOT IMPLEMENT
+  void operator=(const ASTRecordLayout&); // DO NOT IMPLEMENT
 public:
   
   unsigned getAlignment() const { return Alignment; }





More information about the cfe-commits mailing list